vb6 窗体打开15次后自动关闭
我做了个EXE包含两个Form,打开EXE先显示Form2【显示软件剩余试用次数】Form1为主窗体,当用完15次后直接关闭EXE【直接不显示Form1】。a=a+1:L...
我做了个EXE包含两个Form,打开EXE先显示Form2【显示软件剩余试用次数】Form1为主窗体,当用完15次后直接关闭EXE【直接不显示Form1】。
a = a + 1: Label2.Caption = a
If 15 - a >= 0 Then
Else
Unload Me
End If
Open "F:\c.txt" For Random As #1 Len = Len(stu)
Put #1, a, stu
Next a
Close #1
End Sub
Private Sub Command1_Click()
Randomize
Dim bb As i, n
n = 15 - i
Open "F:\c.txt" For Random As #1 Len = Len(bb)
Get #1, n, bb
Label1= bb.name
Close #1
End Sub
如果用文档这样写行吗? 展开
a = a + 1: Label2.Caption = a
If 15 - a >= 0 Then
Else
Unload Me
End If
Open "F:\c.txt" For Random As #1 Len = Len(stu)
Put #1, a, stu
Next a
Close #1
End Sub
Private Sub Command1_Click()
Randomize
Dim bb As i, n
n = 15 - i
Open "F:\c.txt" For Random As #1 Len = Len(bb)
Get #1, n, bb
Label1= bb.name
Close #1
End Sub
如果用文档这样写行吗? 展开
4个回答
展开全部
Form2窗体中共有两个控件,分别是:一个Label1标签、一个Command1按钮。
把下面代码复制到Form2窗体代码中即可。。
Dim s As String
Private Sub Command1_Click()
On Error GoTo err1
If s > 0 Then
s = s - 1
Open "D:\c.txt" For Binary As #1
Put #1, , s
Close #1
Form1.Show
End If
Unload Me
Exit Sub
err1:
MsgBox err.Description
End Sub
Private Sub Form_Load()
On Error GoTo err1
If FileLen("D:\c.txt") = 0 Then
s = 15
Else
Open "D:\c.txt" For Input As #1
Input #1, s
Close #1
End If
Me.Label1 = "软件剩余试用次数:" & s
Exit Sub
err1:
MsgBox err.Description
End Sub
把下面代码复制到Form2窗体代码中即可。。
Dim s As String
Private Sub Command1_Click()
On Error GoTo err1
If s > 0 Then
s = s - 1
Open "D:\c.txt" For Binary As #1
Put #1, , s
Close #1
Form1.Show
End If
Unload Me
Exit Sub
err1:
MsgBox err.Description
End Sub
Private Sub Form_Load()
On Error GoTo err1
If FileLen("D:\c.txt") = 0 Then
s = 15
Else
Open "D:\c.txt" For Input As #1
Input #1, s
Close #1
End If
Me.Label1 = "软件剩余试用次数:" & s
Exit Sub
err1:
MsgBox err.Description
End Sub
展开全部
创建一个文档(例子),内容为0.每次打开时,文档内容为就加1并保存。装载程序时就判定,若大于15就关闭。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'在form2添加如下代码,添加一个Timer1
Private Sub Form_Load()
Dim s1 As String, s2 As String, k As Integer
s1 = App.Path
If Right(s1, 1) <> "\" Then s1 = s1 & "\"
If Dir(s1 & "12.txt") = "" Then
Open s1 & "12.txt" For Output As #1
Print #1, "1"
Close #1
Label1.Caption = "还可使用 14 次!"
Timer1.Interval = 1000
Else
Open s1 & "12.txt" For Input As #1
s2 = Trim(StrConv(InputB(LOF(1), 1), vbUnicode))
Close #1 '
If Val(s2) < 15 Then
Open s1 & "12.txt" For Output As #1
Print #1, Trim(Val(s2) + 1)
Close #1
Label1.Caption = "还可使用 " & 15 - Val(s2) & " 次!"
' Form1.Show
Timer1.Interval = 1000
Else
Label1.Caption = "已使用" & 15 & " 次!"
End If
End If
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 0
Unload Me
Form1.Show
End Sub
Private Sub Form_Load()
Dim s1 As String, s2 As String, k As Integer
s1 = App.Path
If Right(s1, 1) <> "\" Then s1 = s1 & "\"
If Dir(s1 & "12.txt") = "" Then
Open s1 & "12.txt" For Output As #1
Print #1, "1"
Close #1
Label1.Caption = "还可使用 14 次!"
Timer1.Interval = 1000
Else
Open s1 & "12.txt" For Input As #1
s2 = Trim(StrConv(InputB(LOF(1), 1), vbUnicode))
Close #1 '
If Val(s2) < 15 Then
Open s1 & "12.txt" For Output As #1
Print #1, Trim(Val(s2) + 1)
Close #1
Label1.Caption = "还可使用 " & 15 - Val(s2) & " 次!"
' Form1.Show
Timer1.Interval = 1000
Else
Label1.Caption = "已使用" & 15 & " 次!"
End If
End If
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 0
Unload Me
Form1.Show
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询