473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Radio Button question

I need help again if possible!

I want to offer two options for a future user of my program. In Option1(0), the variable resSat must be known and is then used to calculate the variable Mass_BLOB. For Option1(1), it is just the other way around. So if you know one, then the other can be calculated.

So far, I have it that if you select Option1(0), everything calculates correctly from the current input file; however, if i update one of the other variables (such as BLOB_Width), it does not update the variable that is to be calculated, and which is affected by this change. And the second option does not calculate correctly at all. Finally, there seems to be something wrong with the OKButton procedure as the program crashes if it is activated.

This is somewhat confusing i know, but here comes the code for this form:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim i As Integer
  3. Dim Mass_BLOB As Double    ' initial mass
  4. Dim resSat As Double       ' Residual Saturation
  5. ______________________________________________
  6.  
  7. Private Sub Form_Load()
  8.  
  9.     ' make sure that one option is selected (Option1 button)
  10.     Dim allfalse As Boolean
  11.     ' check if one option for description type is selected
  12.     allfalse = True
  13.     For i = 0 To 1
  14.       If index_blob = i Then
  15.          allfalse = False
  16.          Option1(i).Value = True
  17.       End If
  18.     Next i
  19.     'if no option is selected: select 1st
  20.     If allfalse Then Option1(0).Value = True
  21.  
  22.     'Geometry
  23.         For i = 0 To 3
  24.             Text1(i).text = blobzone(i)
  25.             '0: width
  26.             '1: length
  27.             '2: thickness
  28.             '3: depth to contamination
  29.         Next i
  30.  
  31.     'Further characteristics & Blob zone data
  32.         'Time of spill
  33.         Text11.text = gwspilltime(1)
  34.  
  35.         Text3(1).text = Format(blobzone(4), "0.000")   '4: initial mass Blob zone
  36.         Text2(1).text = Format(blobzone(5), "0.00")    '5: Accessability Factor
  37.         Text2(0).text = Format(blobzone(6), "0.00")    '6: Total porosity
  38.         Text3(0).text = Format(blobzone(7), "0.00")    '7: residual saturation
  39.  
  40.     Call update_frame
  41.     Call Estimate_values
  42.  
  43. End Sub
  44. ___________________________________________
  45.  
  46. Private Sub OKButton_Click()
  47.  
  48.     'Check date format
  49.     Dim textlength As Integer
  50.     Dim minuspos As Integer
  51.     Dim iswrong As Integer
  52.  
  53.     iswrong = 0
  54.     textlength = Len(Text11.text)
  55.     minuspos = InStr(Text11.text, "-")
  56.  
  57.     If textlength <> 7 Or minuspos <> 3 Then
  58.        iswrong = 1
  59.        Text11.BackColor = &H6D74F5
  60.     Else
  61.        Text11.BackColor = &HC0C0C0
  62.     End If
  63.  
  64.     If iswrong = 1 Then
  65.  
  66.     Message = MsgBox("Wrong Date Format!", vbOKOnly + vbExclamation)
  67.  
  68.     Else
  69.  
  70.         'Geometry
  71.             For i = 0 To 3
  72.                 If Text1(i).text = "" Then
  73.                     Text1(i).text = 1   
  74.                 End If
  75.             Next i
  76.         'Further characteristics
  77.         For i = 0 To 1
  78.             If Text2(i).text = "" Then Text2(i).text = 0
  79.         Next i
  80.         ' Blob zone data
  81.         For i = 0 To 1
  82.             If Text3(i).text = "" Then Text3(i).text = 1
  83.         Next i
  84.  
  85.         'Geometry
  86.             For i = 0 To 3
  87.                 blobzone(i) = Text1(i).text
  88.                 '0: width
  89.                 '1: length
  90.                 '2: thickness
  91.                 '3: depth to contamination
  92.             Next i
  93.         'Time of spill
  94.         gwspilltime(1) = Text11.text
  95.             If Text11.text = "" Then
  96.                 gwspilltime_inmonths(1) = 0
  97.             Else
  98.                 gwspilltime_inmonths(1) = (Right(Text11.text, 4) - 1900) * 12 + Left(Text11.text, 2)
  99.             End If
  100.  
  101.         blobzone(4) = Text3(1).text    '4: initial mass Blob zone
  102.         blobzone(5) = Text2(1).text    '5: Accessability Factor
  103.         blobzone(6) = Text2(0).text    '6: Total porosity blob zone
  104.         blobzone(7) = Text3(0).text    '7: residual saturation
  105.  
  106.     frmspecific_gwsource_Blob.Visible = False
  107.     Unload frmspecific_gwsource_Blob
  108.  
  109.     End If    ' end of "if iswrong = 1 then ... else"
  110.  
  111.     'set description type (Option1 button)
  112.     For i = 0 To 1
  113.        If Option1(i) = True Then
  114.          index_blob = i
  115.        End If
  116.     Next i
  117.  
  118. End Sub
  119. _________________________________________
  120. Private Sub Option1_Click(Indx As Integer)
  121.  
  122. index_blob = Indx
  123.  
  124. Call update_frame
  125.  
  126. End Sub
  127. __________________________________________-
  128.  
  129. Private Sub CANCELButton_Click()
  130.  
  131. Unload frmspecific_gwsource_Blob
  132. frmspecific_gwsource_Blob.Visible = False
  133.  
  134. End Sub
  135. _____________________________________________________
  136. Private Sub Estimate_values()
  137.  
  138.     Dim Vol_BLOB As Double
  139.     Dim BLOB_Width As Double
  140.     Dim BLOB_Length As Double
  141.     Dim z As Double
  142.     Dim ntot As Double    ' total porosity
  143.     Dim rho As Double     ' rho-NAPL
  144.     Dim theta As Double   ' after Eberhardt&Gratwohl(2002): theta = NAPL porosity: theta = S° * ntot
  145.  
  146.     ' --------------------------------------------------------------------------
  147.     ' determine input values
  148.     ' --------------------------------------------------------------------------
  149.     ' BLOB geometry
  150.     BLOB_Width = Val(Text1(0).text)
  151.     BLOB_Length = Val(Text1(1).text)
  152.     ' BLOB thickness
  153.     z = Val(Text1(2).text)
  154.     ntot = Val(Text2(0).text)
  155.     ' BLOB density
  156.     rho = mixdat_unspec(1)
  157.  
  158.     ' --------------------------------------------------------------------------
  159.     ' calculations
  160.     ' --------------------------------------------------------------------------
  161.  
  162.     'initial volume BLOB
  163.     Vol_BLOB = BLOB_Width * BLOB_Length * z
  164.  
  165.     Select Case index_blob
  166.         'description through residual phase
  167.         Case 0
  168.             resSat = Val(Text3(0).text) / 100
  169.             theta = resSat * ntot     ' NAPL porosity
  170.             ' initial mass calculated from resSat
  171.             Mass_BLOB = Vol_BLOB * 1000 * rho * theta
  172.             'Mass_BLOB = Val(Text3(1).text)
  173.         'description through initial mass
  174.         Case 1
  175.               Mass_BLOB = Val(Text3(1).text)
  176.             ' resSat calculated from initial mass
  177.             resSat = Mass_BLOB / rho * 1000 / (Vol_BLOB * ntot)
  178.             ' theta           ' NAPL porosity
  179.             theta = Text3(0).text * ntot
  180.  
  181.     End Select
  182.     Debug.Print "resSat: " & resSat & " ntot: " & ntot & "Mass_BLOB: " & Mass_BLOB;
  183.  
  184.     Label3.Caption = Format(Vol_BLOB, "0.000")
  185.     Label4.Caption = Format(theta, "0.000000")
  186.     Text3(1).text = Format(blobzone(4), "0.000")
  187.     Text3(0).text = Format(blobzone(7), "0.00")
  188.  
  189. End Sub
  190. ______________________________________________
  191.  
  192. Private Sub update_frame()
  193.  
  194.     Select Case index_blob
  195.     ' description through residual saturation
  196.     Case 0
  197.         Option1(0).Value = True
  198.         Option1(1).Value = False
  199.         Text3(0).BackColor = &HC0C0C0            ' residual saturation can be entered
  200.         Text3(0).Enabled = True
  201.         Text3(1).BackColor = &H808080            ' inital mass is calculated; cannot be entered
  202.         Text3(1).Enabled = False
  203.     ' description through inital mass
  204.     Case 1
  205.         Option1(0).Value = False
  206.         Option1(1).Value = True
  207.         Text3(0).BackColor = &H808080           ' inital mass can be entered
  208.         Text3(0).Enabled = False
  209.         Text3(1).BackColor = &HC0C0C0           ' residual saturation is calculated; cannot be entered
  210.         Text3(1).Enabled = True
  211.     End Select
  212.  
  213. Call Estimate_values
  214.  
  215. End Sub
  216. _______________________________________________
  217. Private Sub UpdateValuesBUTTON_Click()
  218.  
  219.     Call Estimate_values
  220.  
  221. End Sub
________________________________________________

Thanks for helping!!
Donna
Aug 8 '07 #1
5 1421
Killer42
8,435 Expert 8TB
Have you tried stepping through the code? That's one of the most effective debugging techniques. By interrupting the code and then hitting F8 to execute one statement at a time, you can watch exactly what's happening, and examine the values of variables and properties as you go. It's often surprising how different it is to what you thought was happening.
Aug 9 '07 #2
Have you tried stepping through the code? That's one of the most effective debugging techniques. By interrupting the code and then hitting F8 to execute one statement at a time, you can watch exactly what's happening, and examine the values of variables and properties as you go. It's often surprising how different it is to what you thought was happening.

Forgot to say thanks...didnt know about F8ing! have another question now, and will start a new tab. thanks, figured this one out!
Aug 28 '07 #3
Killer42
8,435 Expert 8TB
Forgot to say thanks...didnt know about F8ing! have another question now, and will start a new tab. thanks, figured this one out!
Great! Glad to hear it's sorted. :)

Those debugging tools are well worth learning about.
Aug 29 '07 #4
sgrec7
59
Great! Glad to hear it's sorted. :)

Those debugging tools are well worth learning about.
is there any others that we should know about

BTW. is it bad to necro old threads like this ???
Sep 2 '07 #5
Killer42
8,435 Expert 8TB
is there any others that we should know about
Hm... sounds like a good topic for an article on the Articles area. But briefly, it probably depends on the version of VB you're using. In VB6, you can set breakpoints or watchpoints to interrupt execution at a particular place in the code or when a particular condition is met, respectively. You can step through execution one statement at a time, you can examine and change variables during the interruption. You can also examine the "call stack" to see how you reached this point in the code, but I haven't really used that.

During an interruption (by breakpoint or whatever) you can also, within certain limits, set execution to continue at a different point.

One important tip. Learn the difference between "step into" and "step over" on the Debug menu. This will save you a lot of time and effort.

I have no idea what debugging facilities are available in later versions.


BTW. is it bad to necro old threads like this ???
Probably. Who knows... :)
Sep 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
0
by: hy | last post by:
Hi all, I got the question about the radio button. How do i detect previous checked radio button after i checked other's radio button. While the new radio button checked, it need to prompt out a...
33
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
7
by: nathaniel.k.lee | last post by:
Is it not possible, in IE, to dynamically click a radio button? I'm grabbing some values from a database and using them to populate radio buttons on a page. I have alternate code for Firefox...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
1
by: runway27 | last post by:
hi i have registration form where user selects from a drop down to select their area code apart from filling other details in the form. in the next page which is a confirmation page i would like...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.