FartNocker Posted December 30, 2003 Posted December 30, 2003 Module Module1 Function ResetAllComboBoxesOnMainForm() 'This routine just resets all the conboBoxes text to say "Select" or "0" Dim FormMain As frmMain FormMain = New frmMain FormMain.cboNoNumbers.Text = "Select" FormMain.cboFindMatchingBalls.Text = "Select" FormMain.cboTopBalls.Text = "Select" FormMain.cboRandomPick.Text = "0" End Function End Module I can get hold of the form but cant seem to do anything with the controls. But it gives no errors and thus, runs OK, I'm probably missing one little line here... can someone tell me the secret? Mark Quote
Administrators PlausiblyDamp Posted December 30, 2003 Administrators Posted December 30, 2003 If you are trying to reset the control on a form that is already open your code will not work as it creates a new instance of the form - you need to pass in the existing instance of your form as a parameter: Function ResetAllComboBoxesOnMainForm(FormMain as frmMain) 'This routine just resets all the conboBoxes text to say "Select" or "0" FormMain.cboNoNumbers.Text = "Select" FormMain.cboFindMatchingBalls.Text = "Select" FormMain.cboTopBalls.Text = "Select" FormMain.cboRandomPick.Text = "0" End Function Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
FartNocker Posted December 30, 2003 Author Posted December 30, 2003 A big thanks to you PlausiblyDamp, I have no books on VB net yet. I'm from the earlier days of VB and this stuff about forms not being public gets me. Your example worked great although, In the call to the Function I had to send also the name of the main form such as: Call ResetAllComboBoxesOnMainForm(me) 'or when calling from a form other than the main form I had to use: Call ResetAllComboBoxesOnMainForm(FormMain) Sure will be glad if they decide to make the forms public again:rolleyes: Any ways, Your time was much appreciated by me and probably others. This is a great board... Mark Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.