mercredi 6 mai 2015

VB.net if else convert to case select

hi guys can you help me to convert this to case select statement, this is my first time using case select statement.

If TabControl1.SelectedTab Is tp_5 Then
      myqry = "SELECT * FROM TBLVLAN5 ORDER BY ID"
ElseIf TabControl1.SelectedTab Is tp_7 Then
      myqry = "SELECT * FROM TBLVLAN7 ORDER BY ID"

i search in web but i only found case select statement using integer and string and not the one that fit with my if else example.

i also try use it but its not working, this is my code.

Dim h As String
    h = TabControl1.SelectedTab Is tp_10
    Select Case h
        Case TabControl1.SelectedTab Is tp_5
            myqry = "SELECT * FROM TBLVLAN5 ORDER BY ID"
        Case TabControl1.SelectedTab Is tp_7
            myqry = "SELECT * FROM TBLVLAN7 ORDER BY ID"
        Case TabControl1.SelectedTab Is tp_8
            myqry = "SELECT * FROM TBLVLAN8 ORDER BY ID"
    End Select

any help is greatly appreciated. thanks.

Aucun commentaire:

Enregistrer un commentaire