Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing arguments from many different places to one

Status
Not open for further replies.

lunaclover

Programmer
Joined
Jun 22, 2005
Messages
54
Hi - I'm back! How is everybody?

I'm trying to build nomenclature out and have a subroutine for each section of the build number. One for 'a', one for 'b', one for 'c' and then pass them all into a final build subroutine called BuildNumber, where txtBuildNumber.text = a+b+c+d+e+f+g+h

I'm just doing this to avoid putting a million things after the Handles statement, like I would have to do if I just put it all in one subprocedure. Each selection a user makes in run-time will change sections of the build number in the text box at the bottom of the screen, as they change their selections.

So what am I doing wrong? Here is one example of a section of the build number, followed by the buildnumber procedure itself.

Code:
Private Sub NomenclatureA(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkbox1.CheckedChanged, chkbox2.CheckedChanged, chkbox3.CheckedChanged...

Dim a As String
        If chkbox1.Checked AndAlso chkbox2.Checked Then
            a = "T"
        ElseIf chkbox1.Checked AndAlso chkbox3.Checked Then
            a = "M"
.
.
.
call BuildNumber()
end sub

Private Sub BuildNumber()
        Dim a, b, c, d, e, f, g, h As String

        txtBuildNumber.Text = a+ b+ c+ d+ e+ f+ g+ h
End sub

I tried passing but since only one variable is being passed from each thing, it gets mad that the number of parameters one is passing and the number of parameters the BuildNumber is catching don't match. What is another solution to this? I am trying to keep it neat and clean instead of cramming it all into one subprocedure that Handles 8 million checkboxes, radiobuttons and comboboxes. Is there a way for each subprocedure to pass one variable and then the BuildNumber catch all of them and put them together like I want?

Thanks advance for your help!

Luna
 
You're redefining a in your BuildNumber method. So you set a equal to "T" outside, but then you call BuildNumber, and it uses the local a, which is empty.

It sounds like if you move this line to the top of the class, you should get the behavior you want.
Code:
Dim a, b, c, d, e, f, g, h As String
Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks Chip!
I'm glad it was that simple. I thought I had to pass and catch stuff all over the place, but this works perfectly! I (obviously) am new to vb.net so still learning the basics.

Thanks again!
Luna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top