我正在使用VB.net,我正在尝试创建一个Clear按钮。
我用标签,复选框和文本框解决了所有问题。我遇到的问题是使用组合框中的3个单选按钮。我希望在按下“清除”按钮时默认返回到默认的radButton1。我认为代码就是:
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmWMMainForm
Dim intWMTotal As Integer
Private Sub btnWMExit_Click(sender As Object, e As EventArgs) Handles btnWMExit.Click
'closes the program
Me.Close()
End Sub
Private Sub btnWMClear_Click(sender As Object, e As EventArgs) Handles btnWMClear.Click
'Clears all information
txtWMFee.Text = String.Empty
lblWMAdditional.Text = String.Empty
lblWMDiscount.Text = String.Empty
lblWMDues.Text = String.Empty
chkWMGolf.Checked = False
chkWMRaquetball.Checked = False
chkWMTennis.Checked = False
radWMRegular.Checked = True
End Sub
Private Sub btnWMCalc_Click(sender As Object, e As EventArgs) Handles btnWMCalc.Click
Dim intWMFee As Integer
Dim intWMGolf As Integer = 25
Dim intWMTennis As Integer = 30
Dim intWMRacquetball As Integer = 20
Dim intWMMilitary As Integer = -10
Dim intWMSenior As Integer = -5
Integer.TryParse(txtWMFee.Text, intWMFee)
End Sub
Private Sub radWMMilitary_CheckedChanged(sender As Object, e As EventArgs) Handles radWMMilitary.CheckedChanged
If radWMMilitary.Checked = True Then
lblWMThankyou.Visible = True
Else
lblWMThankyou.Visible = False
End If
End Sub
Private Sub CancelKeys(sender As Object, e As KeyPressEventArgs) Handles txtWMFee.KeyPress
' allows the text box to accept only numbers and
' the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
' cancel the key
e.Handled = True
End If
End Sub
End Class
但这不起作用。有什么想法吗?
**************添加更多信息***************
以下是我正在使用的代码,用于清除按钮。
{{1}}