how pass text to a var number?

srdva59

Active member
Joined
Feb 21, 2009
Messages
28
Programming Experience
Beginner
hi,
when i try do this:

ListView1.Items(a).subitems(TextBox1.Text).text


i receive this error:
Object variable or With block variable not set.

the number in the textbox exist this occor because the var type is not a valid
number but how can i convert?
in other language i don´t have this problem
thanks for your help :)
 
You can convert values using Convert. to whatever you want to. In this case you would want Convert.ToInt32().

VB.NET:
ListView1.Items(a).subitems(Convert.ToInt32(TextBox1.Text)).text

However, I would suggest that instead of a text box you should use a NumericUpDown control instead. You will still need to convert to an integer, but the NUD will give you more control over the values entered, you can set the min and max value.
 
Back
Top