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 1433
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>
<input type="radio" name=p2 value=2>
<input type="radio" name=p2 value=3>
then a text area and a button:
|
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 user clicks on the
"Choose" button of the input field (to select a file on
the local disk), then radio button B is automatically
|
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 confirm message box, if user click on the 'cancel'
button, system will programatically check the previous
radio button instead of the latest radio button that
checked.
|
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 me some kind
of example on how to do this???? I am doing this in asp.net VB.
Please let me know if you need any additional information.
Thanks
|
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 "No", he should
not have the option of clicking on any of the six checkboxes. See Code
attached. Thank you so much in advance for your help as I can't get to
make this combo work.
<p>Did you have any problems finding any of the information...
| |
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 yes to
question 1, the total of yes's increases by 1). I've been searching for
a while but I'm not sure I'm searching with the right keywords. Can
anyone direct me to a source I can review to learn how to do this?
Thanks!
--
|
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 browsers using the
setAttribute() function.
Everything works as planned in Firefox but in IE, the buttons won't
populate and, what's worse, I can't even click on them after everything
loads. I see the slight shadow that indicates you're clicking on a...
|
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 the
form by changing the visible state of the radio buttons and labels
utilising back and next buttons.
E.g. Next button makes current radio buttons and labels invisible and
|
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 to display the select option that a user choose in the first page i am able to display this using a textfield however i would like to display using the select drop down.
following is the code for both select and radio button that i have used.
1....
|
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 6.something I think
and running as a service, Using NoteTab Pro as an IDE (works well). If
you need more, just ask.
In one functioning form:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |