Question Convert controls

kraitz

New member
Joined
Dec 18, 2009
Messages
2
Programming Experience
1-3
I upgraded my application from vb6 to vb.net there're some errors that i need to solve. Please help. it should be easy for you guys as i'm new to vb.net


VB.NET:
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        test(ComboBox1)

    End Sub


    Private Sub test(ByRef test1 As System.Windows.Forms.Control)

 //how do i convert test1 to combobox?
 // as the program doesn't know its a combobox as it doesn't have functions of combobox

    End Sub

not sure if you got what i mean i tried google it it doesn't give me the right results.

thanks.
 
You simply change 'Control' to 'ComboBox'.

Also, change that ByRef to ByVal. ByVal is the default in VB.NET and you should always use it unless you specifically want to assign a new value to the parameter and have that change affect the original variable.
 
{Be hAppy}

Dim Test2 as combobox=ctype(test1,ComboBox)

OR

Change:
Private Sub test(ByRef test1 As System.Windows.Forms.Control)
as
Private Sub test(ByRef test1 As ComboBox)
 
Back
Top