Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring display for Message Boxes

Status
Not open for further replies.
Jun 4, 2003
18
GB
Im just learning how to use VB and though im using VB.Net i only have examples from VB ver.6

Anyway - im attempting to create small program with a message box appearing but am having trouble with the display.caption bit:

Private Sub Test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test.Click
Dim testmsg As Integer
Dim Display As
testmsg = MsgBox("Click to test", 1, "Test Message")
If testmsg = 1 Then
Display.Caption = "Testing Successful"
Else
Display.Caption = "Testing Fail"
End If
End Sub

the problem is it says the word Display has not been declared, but from the notes ive got it doesnt need to be. can anyone help? what should i declare it as???

thanks
 
It looks to me like Display is a label on the form. If there is a label on the form where you are expecting the Testing Successful or Testing Fail to show up, make sure its name is Display. Also, caption is a VB6 property which has been replaced with text. Finally, "Dim Display As" will need to go - this line will cause an error and should not be necessary if you've designed a label in Visual Studio.


Mark [openup]
 
Hi Charlotter,

While there's nothing wrong with Mark's post, you could try this:

Code:
Dim mResult As MsgBoxResult

mResult = MsgBox("Click to test", MsgBoxStyle.AbortRetryIgnore, "Test Message")

    Select Case msgrsltTestMessage
        Case MsgBoxResult.Abort
            Display.Text = "Abort was clicked!"
        Case MsgBoxResult.Retry
            Display.Text = "Retry was clicked!"
        Case MsgBoxResult.Ignore
            Display.Text = "Ignore was clicked!"
    End Select

Hope it helps.
Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top