Private Sub Command1_Click()
Select Case Me.Text1.Text
Case 1
MsgBox ("U Entered 1")
Case 2
MsgBox ("U entered 2")
Case 3
MsgBox ("u entered 3")
Case Default
MsgBox ("Default")
End Select
End Sub

When i enter 4 in textbox1, Msgbox is not displayed.....Default is a valid case or not in VB

Recommended Answers

All 2 Replies

Use "Case Else":

Select Case Me.Text1.Text
    Case 1
        MsgBox ("U Entered 1")
    Case 2
        MsgBox ("U entered 2")
    Case 3
        MsgBox ("u entered 3")
    Case Else
        MsgBox ("Default")
End Select
commented: useful +1

you are wrong Ezzaral case else is not the same as case default:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.