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: - Option Explicit
-
Dim i As Integer
-
Dim Mass_BLOB As Double ' initial mass
-
Dim resSat As Double ' Residual Saturation
-
______________________________________________
-
-
Private Sub Form_Load()
-
-
' make sure that one option is selected (Option1 button)
-
Dim allfalse As Boolean
-
' check if one option for description type is selected
-
allfalse = True
-
For i = 0 To 1
-
If index_blob = i Then
-
allfalse = False
-
Option1(i).Value = True
-
End If
-
Next i
-
'if no option is selected: select 1st
-
If allfalse Then Option1(0).Value = True
-
-
'Geometry
-
For i = 0 To 3
-
Text1(i).text = blobzone(i)
-
'0: width
-
'1: length
-
'2: thickness
-
'3: depth to contamination
-
Next i
-
-
'Further characteristics & Blob zone data
-
'Time of spill
-
Text11.text = gwspilltime(1)
-
-
Text3(1).text = Format(blobzone(4), "0.000") '4: initial mass Blob zone
-
Text2(1).text = Format(blobzone(5), "0.00") '5: Accessability Factor
-
Text2(0).text = Format(blobzone(6), "0.00") '6: Total porosity
-
Text3(0).text = Format(blobzone(7), "0.00") '7: residual saturation
-
-
Call update_frame
-
Call Estimate_values
-
-
End Sub
-
___________________________________________
-
-
Private Sub OKButton_Click()
-
-
'Check date format
-
Dim textlength As Integer
-
Dim minuspos As Integer
-
Dim iswrong As Integer
-
-
iswrong = 0
-
textlength = Len(Text11.text)
-
minuspos = InStr(Text11.text, "-")
-
-
If textlength <> 7 Or minuspos <> 3 Then
-
iswrong = 1
-
Text11.BackColor = &H6D74F5
-
Else
-
Text11.BackColor = &HC0C0C0
-
End If
-
-
If iswrong = 1 Then
-
-
Message = MsgBox("Wrong Date Format!", vbOKOnly + vbExclamation)
-
-
Else
-
-
'Geometry
-
For i = 0 To 3
-
If Text1(i).text = "" Then
-
Text1(i).text = 1
-
End If
-
Next i
-
'Further characteristics
-
For i = 0 To 1
-
If Text2(i).text = "" Then Text2(i).text = 0
-
Next i
-
' Blob zone data
-
For i = 0 To 1
-
If Text3(i).text = "" Then Text3(i).text = 1
-
Next i
-
-
'Geometry
-
For i = 0 To 3
-
blobzone(i) = Text1(i).text
-
'0: width
-
'1: length
-
'2: thickness
-
'3: depth to contamination
-
Next i
-
'Time of spill
-
gwspilltime(1) = Text11.text
-
If Text11.text = "" Then
-
gwspilltime_inmonths(1) = 0
-
Else
-
gwspilltime_inmonths(1) = (Right(Text11.text, 4) - 1900) * 12 + Left(Text11.text, 2)
-
End If
-
-
blobzone(4) = Text3(1).text '4: initial mass Blob zone
-
blobzone(5) = Text2(1).text '5: Accessability Factor
-
blobzone(6) = Text2(0).text '6: Total porosity blob zone
-
blobzone(7) = Text3(0).text '7: residual saturation
-
-
frmspecific_gwsource_Blob.Visible = False
-
Unload frmspecific_gwsource_Blob
-
-
End If ' end of "if iswrong = 1 then ... else"
-
-
'set description type (Option1 button)
-
For i = 0 To 1
-
If Option1(i) = True Then
-
index_blob = i
-
End If
-
Next i
-
-
End Sub
-
_________________________________________
-
Private Sub Option1_Click(Indx As Integer)
-
-
index_blob = Indx
-
-
Call update_frame
-
-
End Sub
-
__________________________________________-
-
-
Private Sub CANCELButton_Click()
-
-
Unload frmspecific_gwsource_Blob
-
frmspecific_gwsource_Blob.Visible = False
-
-
End Sub
-
_____________________________________________________
-
Private Sub Estimate_values()
-
-
Dim Vol_BLOB As Double
-
Dim BLOB_Width As Double
-
Dim BLOB_Length As Double
-
Dim z As Double
-
Dim ntot As Double ' total porosity
-
Dim rho As Double ' rho-NAPL
-
Dim theta As Double ' after Eberhardt&Gratwohl(2002): theta = NAPL porosity: theta = S° * ntot
-
-
' --------------------------------------------------------------------------
-
' determine input values
-
' --------------------------------------------------------------------------
-
' BLOB geometry
-
BLOB_Width = Val(Text1(0).text)
-
BLOB_Length = Val(Text1(1).text)
-
' BLOB thickness
-
z = Val(Text1(2).text)
-
ntot = Val(Text2(0).text)
-
' BLOB density
-
rho = mixdat_unspec(1)
-
-
' --------------------------------------------------------------------------
-
' calculations
-
' --------------------------------------------------------------------------
-
-
'initial volume BLOB
-
Vol_BLOB = BLOB_Width * BLOB_Length * z
-
-
Select Case index_blob
-
'description through residual phase
-
Case 0
-
resSat = Val(Text3(0).text) / 100
-
theta = resSat * ntot ' NAPL porosity
-
' initial mass calculated from resSat
-
Mass_BLOB = Vol_BLOB * 1000 * rho * theta
-
'Mass_BLOB = Val(Text3(1).text)
-
'description through initial mass
-
Case 1
-
Mass_BLOB = Val(Text3(1).text)
-
' resSat calculated from initial mass
-
resSat = Mass_BLOB / rho * 1000 / (Vol_BLOB * ntot)
-
' theta ' NAPL porosity
-
theta = Text3(0).text * ntot
-
-
End Select
-
Debug.Print "resSat: " & resSat & " ntot: " & ntot & "Mass_BLOB: " & Mass_BLOB;
-
-
Label3.Caption = Format(Vol_BLOB, "0.000")
-
Label4.Caption = Format(theta, "0.000000")
-
Text3(1).text = Format(blobzone(4), "0.000")
-
Text3(0).text = Format(blobzone(7), "0.00")
-
-
End Sub
-
______________________________________________
-
-
Private Sub update_frame()
-
-
Select Case index_blob
-
' description through residual saturation
-
Case 0
-
Option1(0).Value = True
-
Option1(1).Value = False
-
Text3(0).BackColor = &HC0C0C0 ' residual saturation can be entered
-
Text3(0).Enabled = True
-
Text3(1).BackColor = &H808080 ' inital mass is calculated; cannot be entered
-
Text3(1).Enabled = False
-
' description through inital mass
-
Case 1
-
Option1(0).Value = False
-
Option1(1).Value = True
-
Text3(0).BackColor = &H808080 ' inital mass can be entered
-
Text3(0).Enabled = False
-
Text3(1).BackColor = &HC0C0C0 ' residual saturation is calculated; cannot be entered
-
Text3(1).Enabled = True
-
End Select
-
-
Call Estimate_values
-
-
End Sub
-
_______________________________________________
-
Private Sub UpdateValuesBUTTON_Click()
-
-
Call Estimate_values
-
-
End Sub
________________________________________________
Thanks for helping!!
Donna
5 1421
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.
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!
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.
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 ???
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... :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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>...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |