variable to command?

aliasmortal

Member
Joined
Feb 26, 2008
Messages
6
Programming Experience
1-3
Hey all,

I am really new to VB.net and I also haven't done much programming in the last 6 years, so basically I suck at it. So here is my question, I am sure it is really simple and any help would be great.

I want to use a variable as part of a command like this.

Original command - MsgBox(combobox1.text)

Need to change to something like this - MsgBox(var1.text) var1 would be combobox1

Where var1 would be the name of a var I would pass to a function etc....
 
Here's a simple demo to get you started.
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim var1 As String

        For x As Integer = 0 To 9
            Me.ComboBox1.Items.Add("Item " & x.ToString())
        Next

        Me.ComboBox1.SelectedIndex = 5

        var1 = Me.ComboBox1.SelectedItem.ToString()
        MessageBox.Show(var1)
        'var1 should equal "Item 5"
    End Sub
 
VB.NET:
dim combo as combobox = me.controls("combobox1")
msgbox(combo.text)
 
I have to write my program in vb6 unfortunately because I need it to run in a windows PE environment, more specifically Barts PE and for some reason .net will not run in that environment. It's really unfortunate, I was really starting to get to like .net.
 
Back
Top