Beginning VB 6For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
I have two forms, I am passing a value from an on click sub procedure that creates and shows a form to the form that is called but I am unsuccessful.
Do I have to create the form in the on click procedure using the new form and pass it to a procedure within that new form or can I pass it another way?
You question is a bit vague but I believe your problem could be solved with the use of a global variable. The way I do this is to create a seperate module for my globals and assign their values when I need them .. like this.
Public gmyGlobal as DataType (whatever it needs to be string, integer, ect)
----------------------------------------------------------------
Private Sub Command1_Click()
gmyGlobal = Value
Form2.show
End Sub
----------------------------------------------------------
If you do it this way the value will be retained even if you unload the initial form. You do have to keep in mind that the global variable will hold the value you assign it until you either reassign it or end the program. My point there is you always need to be aware of it's value when using it in multiple places throughout your application or you may get some unexpected results.