还有一个vb问题

 

求助:下面的运行出来,提示:编译错误:在end sub,end function,或end属性后只能出现注释。

这是为什么啊?望高人指点啊.

 

Private Sub Form_Load()
Dim machine As String
Dim machine_decode As String
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
machine = GetSerialNumber("c:")
machine_decode = getserial()
Text1.Text = machine
txtsql = "select * from userenroll_info where machine = '" & machine & "' and decode='" & machine_decode & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF Then
MsgBox "没有注册信息!"
 cmdok.Visible = False
 cmdenroll.Visible = True
Else
MsgBox "找到注册信息"
cmdok.Visible = True
cmdenroll.Visible = False
Label2.Visible = False
Label3.Visible = False
Text1.Visible = False
Text2.Visible = False
End If
Set mrc = Nothing
End Sub
Private Sub cmdok_click()
Unload Me
frmmain.Show
End Sub
Private Sub cmdcancel_click()
End
End Sub
Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Res = GetVolumeInfomation(strDrive, Temp1, Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = SerialNum
End Function

Function getserial() As String
Dim inputserial As String
Dim n As String
Dim n1 As String
Dim n2 As String
Dim p As Long
Dim p1 As Long
Dim p2 As Long
Dim i As Long
p = 0
p1 = 0
p2 = 0
n = ""
n1 = ""
n2 = ""
n = Str(GetSerialNumber("c:"))
n1 = ""
n2 = ""
If Len(n) < 20 Then
n = n + String(20 - Len(n), "z")
n1 = n1 + String(20 - Len(n), "A")
n2 = n2 + String(20 - Len(n2), "H")
End If
For i = 1 To 20
p = p + Asc(Mid(n, i, 1)) * 199
p1 = p1 + Asc(Mid(n1, i, 1)) * 179
p2 = p2 + Asc(Mid(n2, i, 1)) * 109
Next
inputseial = Format(p) + "-" + Format(p1) + "-" + Format(p2)
getserialn = inputseial
End Function
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long

Private Sub cmdenroll_Click()
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim msdtext As String
If Len(Text2.Text) <> 20 Then
MsgBox "您输入的注册码错误!"
Exit Sub
If Text2.Text <> getsrialn() Then
MsgBox "注册码错误,请重新输入!"
Exit Sub
End If
On Error GoTo err1
txtsql = "INSERT INTO userenroll_info(machine,decode) values('" & Text1.Text & "','" & Text2.Text & "')"
Set mrc = ExecuteSQL(txtsql, msgtext)
MsgBox "注册成功!"
cmdok.Visible = True
cmdenroll.Visible = False
Label2.Visible = False
Label3.Visible = False
Text1.Visible = False
Text2.Visible = False
Exit Sub
errl:
MsgBox "添加注册信息失败!"
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值