Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

OK, here is the dumb question of the day.

 

I have a array that is filled by a user making choices. It is currently dimmed as:

 

Friend gstrAssemblyRemarker() As String

 

The first time I use gstrAssemblyRemarker I get an error because it is nothing. How can I instantiate it and set a default value so that it looks like:

 

Friend gstrAssemblyRemarker() As String = ?

 

I cannot just check for nothing. There are 42 controls that this could apply to and I have no way of knowing which or how many will be selected.

 

Thanks

 

P.S. There is not a better way of doing this. I have to have 42 controls.

Posted

Why not have an array of your controls? So if you're working with textboxes, you'd do:

 

friend myTextboxes() as Textbox = new Textbox(42)

 

then have some startup code that assigns your textboxes into this array -

myTextboxes(0) = txtSometext1

...

myTextboxes(41) = txtSometext42

 

There's other approaches you can take here, but if you're set on an array of controls, this should work.

  • *Experts*
Posted

If I understand your question correctly....

You could set an UpperBound value to the array

Dim gstrAssemblyRemarker(0) As String

 

With that then check the UpperBound value and if it = Nothing:

If gstrAssemblyRemarker.GetUpperBound(0) = Nothing Then ....OR in a loop:

 

For i = 0 to gstrAssemblyRemarker.GetUpperBound(0)

If Not gstrAssemblyRemarker(i) = Nothing Then

'blah

End If

Next

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

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...