AdvancedHMI Software

General Category => Support Questions => Topic started by: Darrell on August 31, 2015, 08:12:56 AM

Title: msgbox for button
Post by: Darrell on August 31, 2015, 08:12:56 AM
I used this code that i found on this forum and I maybe missing something.
when i click a button to toggle a bit the message pops up with a yes or no question but the bit still toggles before I answer.


If MsgBox("Are you sure?", Microsoft.VisualBasic.MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            EthernetIPforPLCSLCMicroCom1.Write("B3/100", "1")
        End If

Darrell
Title: Re: msgbox for button
Post by: Cowboy1 on August 31, 2015, 11:59:44 AM
I used this code that i found on this forum and I maybe missing something.
when i click a button to toggle a bit the message pops up with a yes or no question but the bit still toggles before I answer.


If MsgBox("Are you sure?", Microsoft.VisualBasic.MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            EthernetIPforPLCSLCMicroCom1.Write("B3/100", "1")
        End If

Darrell

Darrell,

I think this may work:

 If   
    MsgBox("Are you sure?", Microsoft.VisualBasic.MsgBoxStyle.YesNo)
EndIf

      If
        MsgBoxResult.Yes Then
            EthernetIPforPLCSLCMicroCom1.Write("B3/100", "1")
     End If
Title: Re: msgbox for button
Post by: Godra on August 31, 2015, 03:11:56 PM
I couldn't have that code work but this one did work:

Code: [Select]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim result As MsgBoxResult = MsgBox("Are you sure?", Microsoft.VisualBasic.MsgBoxStyle.YesNo)
        If result = MsgBoxResult.Yes Then
            EthernetIPforPLCSLCMicroCom1.Write("B3/100", "1")
        End If
    End Sub