Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...