用VB编写一个清除复原的按钮

来源:百度知道 编辑:UC知道 时间:2024/06/27 05:00:09
添加了一个按钮,一个文本框 代码如下就是不知道为什么不能复原了呢 哪位高手给看看呢,新学很有问题
Dim storestring As String
Private Sub Command1_Click()

If Command1.Caption = "清除" Then
strorestring = Text1.Text
Text1.Text = ""
Command1.Caption = "复原"
Else
Text1.Text = storestring
Command1.Caption = "清除"
End If

Dim storestring As String
strorestring = Text1.Text
你没发现有什么错误吗?
拼写错误。

If Command1.Caption = "清除" Then
strorestring = Text1.Text
Text1.Text = ""
Command1.Caption = "复原"

strorestring = Text1.Text
这句你倒过来了吧。。

Dim a As String
Private Sub Command1_Click()
If Command1.Caption = "清除" Then
a = Text1.Text
Text1.Text = ""
Command1.Caption = "复原"
Else
Text1.Text = a
Command1.Caption = "清除"
End If
End Sub
这样我运行了一下,感觉正确啊

Dim storestring As String
Private Sub Command1_Click()

If Command1.Caption = "清除" Then
strorestring = Text1.Text
你的变量写错了在通用中的"storestring"你写成了"strorestring"你少写了一个"r" 变量不要写得怎么复杂吧, 写简单一点这样就没有那么容易出错了,呵呵以后注意一点