Vb.net Msgbox和vbyesnocancel
大家好,我在msgbox提示vbyesnocancel时遇到了一些问题 •此代码“一切正常”,但“我需要单击多个是、否、取消以激活其功能Vb.net Msgbox和vbyesnocancel,vb.net,Vb.net,大家好,我在msgbox提示vbyesnocancel时遇到了一些问题 •此代码“一切正常”,但“我需要单击多个是、否、取消以激活其功能 Private Sub cbEnableDeductions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEnableDeductions.Click If MsgBox("Do You want To Enable deduct
Private Sub cbEnableDeductions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEnableDeductions.Click
If MsgBox("Do You want To Enable deductions?", vbYesNoCancel) = MsgBoxResult.Yes Then
cbEnableDeductions.Checked = True
txtSSS.Enabled = True
txtHDMF.Enabled = True
txtPhilHealth.Enabled = True
ElseIf MsgBox("Do You want To Enable deductions?", vbYesNoCancel) = MsgBoxResult.No Then
cbEnableDeductions.Checked = True
Total()
ElseIf MsgBox("Do You want To Enable deductions?", vbYesNoCancel) = MsgBoxResult.Cancel Then
cbEnableDeductions.CheckState = False
End If
End Sub
•在该代码下,“否”和“取消”功能不起作用
Private Sub cbEnableDeductions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEnableDeductions.Click
If MsgBox("Do You want To Enable deductions?", vbYesNoCancel) = MsgBoxResult.Yes Then
cbEnableDeductions.Checked = True
txtSSS.Enabled = True
txtHDMF.Enabled = True
txtPhilHealth.Enabled = True
ElseIf vbYesNoCancel = MsgBoxResult.No Then
cbEnableDeductions.Checked = True
Total()
ElseIf vbYesNoCancel = MsgBoxResult.Cancel Then
cbEnableDeductions.CheckState = False
End If
End Sub
尝试此操作,您将使用现有代码请求输入3次
Dim result As MsgBoxResult = MsgBox("Do You want To Enable deductions?", vbYesNoCancel)
If result = MsgBoxResult.Yes Then
cbEnableDeductions.Checked = True
txtSSS.Enabled = True
txtHDMF.Enabled = True
txtPhilHealth.Enabled = True
ElseIf result = MsgBoxResult.No Then
cbEnableDeductions.Checked = True
Total()
ElseIf result = MsgBoxResult.Cancel Then
cbEnableDeductions.CheckState = False
End If
或者你可以用一个箱子
Select Case MsgBox("Do You want To Enable deductions?", vbYesNoCancel)
Case MsgBoxResult.Yes
cbEnableDeductions.Checked = True
txtSSS.Enabled = True
txtHDMF.Enabled = True
txtPhilHealth.Enabled = True
Case MsgBoxResult.No
cbEnableDeductions.Checked = True
Total()
Case MsgBoxResult.Cancel
cbEnableDeductions.CheckState = False
End Select
试着这样做:
Private Sub cbEnableDeductions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEnableDeductions.Click
Dim msgBoxResult = MsgBox("Do You want To Enable deductions?", vbYesNoCancel)
If msgBoxResult = MsgBoxResult.Yes Then
cbEnableDeductions.Checked = True
txtSSS.Enabled = True
txtHDMF.Enabled = True
xtPhilHealth.Enabled = True
ElseIf msgBoxResult = MsgBoxResult.No Then
cbEnableDeductions.Checked = True
Total()
ElseIf msgBoxResult = MsgBoxResult.Cancel Then
cbEnableDeductions.CheckState = False
End If
End Sub
您确实应该使用MessageBox.Show()而不是传统的MsgBox()函数。我看到MsgBox有一些细微的错误,对话框不能正确地显示在应用程序前面。哦,我不能,我需要15个代表点,对不起,先生,我在stackoverflow只是新来的