Message Box demonstrator problem

Hi - I wonder if anyone could help me please. Im a complete novice at visual basic. Im currently trying to learn VB.net from a book (without much success).
Im trying to write the source code for a Message Box demonstrator with the use of Radio buttons and Group boxes.
Basically there are two group boxes one either side with radio buttons inserted onto them.
For each button selected a different icon should appear in the message box. Im trying to use If.else endif to do this.
The code I have written for the selection of 2 together buttons doesnt work (Its Ok for just one button). Instead the program just runs through the three conditions and displays the 3 different message boxes one after the other. Any Ideas???

If OKButton.Checked = True Then
MessageBox.Show("", "", MessageBoxButtons.OK)
End If

If (HandButton.Checked = True) Then
MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End If

If (HandButton.Checked And OKButton.Checked = True) Then
MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End If

Many Thanks
Paul37


Comments

  • : Hi - I wonder if anyone could help me please. Im a complete novice at visual basic. Im currently trying to learn VB.net from a book (without much success).
    : Im trying to write the source code for a Message Box demonstrator with the use of Radio buttons and Group boxes.
    : Basically there are two group boxes one either side with radio buttons inserted onto them.
    : For each button selected a different icon should appear in the message box. Im trying to use If.else endif to do this.
    : The code I have written for the selection of 2 together buttons doesnt work (Its Ok for just one button). Instead the program just runs through the three conditions and displays the 3 different message boxes one after the other. Any Ideas???
    :
    : If OKButton.Checked = True Then
    : MessageBox.Show("", "", MessageBoxButtons.OK)
    : End If
    :
    : If (HandButton.Checked = True) Then
    : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : End If
    :
    : If (HandButton.Checked And OKButton.Checked = True) Then
    : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : End If
    :
    : Many Thanks
    : Paul37
    :
    :
    :
    I'm not real clear on where you are putting the code at. Also the last two conditions will show the same icon any way. And you can't have two radio buttons pressed at the same time unless they are in different GroupBoxes. I did what it sounds like you want to do like this:

    Private Sub rbnInfo_Click(...)
    MessageBox.Show("Info","", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub rbnHand_Click(...)
    MessageBox.Show("Exclamation","",MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    End Sub

    Provate Sub rbnStop_Click(...)
    MessageBox.SHow("Stop","",MessageBoxButtons.OK,MessageBosIcon.Stop)
    End Sub

    where the rbn...'s are radio buttons. By the way, even though there are a number of icons enumerated, some of them show the same symbol. Tell me where you were placing the code and we'll see if we can sort out where your code is not doing what's expected.
  • : : Hi - I wonder if anyone could help me please. Im a complete novice at visual basic. Im currently trying to learn VB.net from a book (without much success).
    : : Im trying to write the source code for a Message Box demonstrator with the use of Radio buttons and Group boxes.
    : : Basically there are two group boxes one either side with radio buttons inserted onto them.
    : : For each button selected a different icon should appear in the message box. Im trying to use If.else endif to do this.
    : : The code I have written for the selection of 2 together buttons doesnt work (Its Ok for just one button). Instead the program just runs through the three conditions and displays the 3 different message boxes one after the other. Any Ideas???
    : :
    : : If OKButton.Checked = True Then
    : : MessageBox.Show("", "", MessageBoxButtons.OK)
    : : End If
    : :
    : : If (HandButton.Checked = True) Then
    : : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : : End If
    : :
    : : If (HandButton.Checked And OKButton.Checked = True) Then
    : : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : : End If
    : :
    : : Many Thanks
    : : Paul37
    : :
    : :
    : :
    : I'm not real clear on where you are putting the code at. Also the last two conditions will show the same icon any way. And you can't have two radio buttons pressed at the same time unless they are in different GroupBoxes. I did what it sounds like you want to do like this:
    :
    : Private Sub rbnInfo_Click(...)
    : MessageBox.Show("Info","", MessageBoxButtons.OK, MessageBoxIcon.Information)
    : End Sub
    :
    : Private Sub rbnHand_Click(...)
    : MessageBox.Show("Exclamation","",MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    : End Sub
    :
    : Provate Sub rbnStop_Click(...)
    : MessageBox.SHow("Stop","",MessageBoxButtons.OK,MessageBosIcon.Stop)
    : End Sub
    :
    : where the rbn...'s are radio buttons. By the way, even though there are a number of icons enumerated, some of them show the same symbol. Tell me where you were placing the code and we'll see if we can sort out where your code is not doing what's expected.
    :

    Hi thanks for your response - I'm very sorry - I didnt explain very clearly what I'm trying to do.

    Ive created 2 group boxes both containing several radio buttons. The first contains buttons such as OK/OKCancel etc.

    The second radio buttons if selected (with a ShowButton) on their own or more often with a radio button from the first group box - will display along with the massage box - an icon also such as Hand/error etc. Therefore some of the messages will be the same.

    The conditions Ive written seem to display the correct messages/icons but if the second or third are chosen - all three messages are activated.

    I would like it to jump to the correct condition and display only the correct message/icon

    Thank you for your time - I'm very grateful.
    Paul37




  • : Hi - I wonder if anyone could help me please. Im a complete novice at visual basic. Im currently trying to learn VB.net from a book (without much success).
    : Im trying to write the source code for a Message Box demonstrator with the use of Radio buttons and Group boxes.
    : Basically there are two group boxes one either side with radio buttons inserted onto them.
    : For each button selected a different icon should appear in the message box. Im trying to use If.else endif to do this.
    : The code I have written for the selection of 2 together buttons doesnt work (Its Ok for just one button). Instead the program just runs through the three conditions and displays the 3 different message boxes one after the other. Any Ideas???
    :
    : If OKButton.Checked = True Then
    : MessageBox.Show("", "", MessageBoxButtons.OK)
    : End If
    :
    : If (HandButton.Checked = True) Then
    : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : End If
    :
    : If (HandButton.Checked And OKButton.Checked = True) Then
    : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : End If
    :
    : Many Thanks
    : Paul37
    :
    :
    :
    You should try using a case statment instead of all those if end ifs.

    Select Case WhichRadioButtonTicked

    Case OKButton.Checked = True
    MessageBox.Show(("", "", MessageBoxButtons.OK)

    Case HandButton.Checked = True
    MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)

    Case HandButton.Checked And OKButton.Checked = True
    MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)

    End Select

    Or you could put all your if end if statments into a seperate sub and call them when with the case select method.


  • : : Hi - I wonder if anyone could help me please. I’m a complete novice at visual basic. I’m currently trying to learn VB.net from a book (without much success).
    : : I’m trying to write the source code for a Message Box demonstrator with the use of Radio buttons and Group boxes.
    : : Basically there are two group boxes one either side with radio buttons inserted onto them.
    : : For each button selected a different icon should appear in the message box. I’m trying to use If….else… endif to do this.
    : : The code I have written for the selection of 2 together buttons doesn’t work (Its Ok for just one button). Instead the program just runs through the three conditions and displays the 3 different message boxes one after the other. Any Ideas???
    : :
    : : If OKButton.Checked = True Then
    : : MessageBox.Show("", "", MessageBoxButtons.OK)
    : : End If
    : :
    : : If (HandButton.Checked = True) Then
    : : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : : End If
    : :
    : : If (HandButton.Checked And OKButton.Checked = True) Then
    : : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    : : End If
    : :
    : : Many Thanks
    : : Paul37
    : :
    : :
    : :
    : You should try using a case statment instead of all those if end ifs.
    :
    : Select Case WhichRadioButtonTicked
    :
    : Case OKButton.Checked = True
    : MessageBox.Show(("", "", MessageBoxButtons.OK)
    :
    : Case HandButton.Checked = True
    : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    :
    : Case HandButton.Checked And OKButton.Checked = True
    : MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    :
    : End Select
    :
    : Or you could put all your if end if statments into a seperate sub and call them when with the case select method.
    :
    :
    : Thanks - I'll try this.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories