how do I make "vb YesNo" cancel a record when I say "No" or something similar

0
  If MsgBox("¿seguro que desea votar por este partido?", vbYesNo, "Información") = vbYes Then
        MsgBox("Su voto se ah realizado", vbOKOnly, "Información")
    Else
        MsgBox("Su voto se ah cancelado", vbOKOnly, "Información")
    End If

I have this line but when I want to "cancel my registration" and I give "no" even though it is stored in the database, how do I solve it?

    
asked by fabro 01.12.2017 в 15:18
source

1 answer

0

Try this method:

Suppose the record is sent to a Label (You did not specify where it was registered)

Dim Texto, Texto2, Título As String 'Texto2 es lo del segundo MsgBox.
Dim Estilo, Estilo2 As MsgBoxStyle
Dim Respuesta As MsgBoxResult


Texto = "¿seguro que desea votar por este partido?"
Estilo = MsgBoxStyle.Question Or MsgBoxStyle.DefaultButton2 Or 
MsgBoxStyle.YesNo
Título = "Información"

Respuesta = MsgBox(Texto, Estilo, Título)
If Respuesta = MsgBoxResult.Yes Then
  Texto2 = "Su voto se ha realizado"
  Estilo2 = MsgBoxStyle.Information Or MsgBoxStyle.DefaultButton1 Or MsgBoxStyle.OkOnly
  ResultadoLabel.Text = "Voto Confirmado"
  MsgBox(Texto2, Estilo2, Título)
ElseIf Respuesta = MsgBoxResult.No Then
  Texto2 = "Su voto se ha cancelado"
  Estilo2 = MsgBoxStyle.Information Or MsgBoxStyle.DefaultButton1 Or 
 MsgBoxStyle.OkOnly
 MsgBox(Texto2, Estilo2, Título)
 End If

With this, if the answer is No, it will not confirm anything; But if the answer is "Yes" it will be recorded in the Label.

    
answered by 18.12.2017 в 05:22