提示错误“在End Sub、 End Function或 End属性后面只能出现注释”
这个问题困扰了我好几点,问题主要出现在源代码快写到结尾的“Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long”这个源代码开始,我删除一组Private语句,系统就提示下一组Private出错,而且出错都是提示错误“在End Sub、 End Function或 End属性后面只能出现注释”
请问我现在该如何去做,才能解决这个问题。
源代码如下:
============================分隔线====================================
Public symm As String
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type RASIPADDR
a As Byte
b As Byte
c As Byte
d As Byte
End Type
Private Type RASENTRY
dwSize As Long
dwfOptions As Long
dwCountryID As Long
dwCountryCode As Long
szAreaCode(10) As Byte
szLocalPhoneNumber(128) As Byte
dwAlternateOffset As Long
ipaddr As RASIPADDR
ipaddrDns As RASIPADDR
ipaddrDnsAlt As RASIPADDR
ipaddrWins As RASIPADDR
ipaddrWinsAlt As RASIPADDR
dwFrameSize As Long
dwfNetProtocols As Long
dwFramingProtocol As Long
szScript(259) As Byte
szAutodialDll(259) As Byte
szAutodialFunc(259) As Byte
szDeviceType(16) As Byte
szDeviceName(128) As Byte
szX25PadType(32) As Byte
szX25Address(200) As Byte
szX25Facilities(200) As Byte
szX25UserData(200) As Byte
dwChannels As Long
dwReserved1 As Long
dwReserved2 As Long
dwSubEntries As Long
dwDialMode As Long
dwDialExtraPercent As Long
dwDialExtraSampleSeconds As Long
dwHangUpExtraPercent As Long
dwHangUpExtraSampleSeconds As Long
dwIdleDisconnectSeconds As Long
dwType As Long
dwEncryptionType As Long
dwCustomAuthKey As Long
guidId As GUID
szCustomDialDll(259) As Byte
dwVpnStrategy As Long
dwfOptions2 As Long
dwfOptions3 As Long
szDnsSuffix(255) As Byte
dwTcpWindowSize As Long
szPrerequisitePbk(259) As Byte
szPrerequisiteEntry(256) As Byte
dwRedialCount As Long
dwRedialPause As Long
End Type
Private Type RASCREDENTIALS
dwSize As Long
dwMask As Long
szUserName(256) As Byte
szPassword(256) As Byte
szDomain(15) As Byte
End Type
Private Declare Function RasSetEntryProperties Lib "rasapi32" Alias "RasSetEntryPropertiesA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, lpRasEntry As RASENTRY, ByVal dwEntryInfoSize As Long, ByVal lpbDeviceInfo As Long, ByVal dwDeviceInfoSize As Long) As Long
Private Declare Function RasSetCredentials Lib "rasapi32" Alias "RasSetCredentialsA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, lpCredentials As RASCREDENTIALS, ByVal fClearCredentials As Long) As Long
Private Sub CmdConnect_Click() '创建拨号连接按钮开始
'Dim sEntryName As String, sUsername As String, sPassword As String
sEntryName = TxtLJ.Text
sUsername = TxtYHM.Text
sPassword = TxtMM.Text
If Len(TxtYHM.Text) <> 0 And Len(TxtMM.Text) <> 0 Then
If Create_PPPoE_Connection(sEntryName, sUsername, sPassword) Then
MsgBox "连接建立成功!"
Else
MsgBox "连接建立失败!"
End If
Else
MsgBox "用户名或密码为空!", vbOKOnly, "诶,请你认真一点..."
End If
End Sub '创建拨号连接按钮结束
Function Create_PPPoE_Connection(ByVal sEntryName As String, ByVal sUsername As String, ByVal sPassword As String) As Boolean '创建宽带连接
Create_PPPoE_Connection = False
Dim re As RASENTRY
Dim sDeviceName As String, sDeviceType As String
sDeviceName = "WAN 微型端口 (PPPOE)"
sDeviceType = "PPPoE"
With re
.dwSize = LenB(re)
.dwCountryCode = 86
.dwCountryID = 86
.dwDialExtraPercent = 75
.dwDialExtraSampleSeconds = 120
.dwDialMode = 1
.dwEncryptionType = 3
.dwfNetProtocols = 4
.dwfOptions = 1024262928
.dwfOptions2 = 367
.dwFramingProtocol = 1
.dwHangUpExtraPercent = 10
.dwHangUpExtraSampleSeconds = 120
.dwRedialCount = 3
.dwRedialPause = 60
.dwType = 5
CopyMemory .szDeviceName(0), ByVal sDeviceName, Len(sDeviceName)
CopyMemory .szDeviceType(0), ByVal sDeviceType, Len(sDeviceType)
End With
Dim rc As RASCREDENTIALS
With rc
.dwSize = LenB(rc)
.dwMask = 11
CopyMemory .szUserName(0), ByVal sUsername, Len(sUsername)
CopyMemory .szPassword(0), ByVal sPassword, Len(sPassword)
End With
Dim rtn As Long
If RasSetEntryProperties(vbNullString, sEntryName, re, LenB(re), 0, 0) = 0 Then
If RasSetCredentials(vbNullString, sEntryName, rc, 0) = 0 Then
Create_PPPoE_Connection = True
End If
End If
End Function
Private Sub Command2_Click() '开始拨号按钮开始
'Dim recAdConn&
If Len(TxtYHM.Text) <> 0 And Len(TxtMM.Text) <> 0 Then
recAdConn = AddConnection(TxtLJ.Text, "", "", TxtYHM.Text, TxtMM.Text, "")
Else
MsgBox "用户名或密码为空!", vbOKOnly, "诶,请你认真一点..."
End If
End Sub '开始拨号按钮结束
Private Sub Command3_Click() '断开网络按钮开始
HangUpAll
End Sub '断开网络按钮结束
Private Sub Command4_Click() '退出按钮开始
Unload Me
End Sub '退出按钮结束
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
End Sub
Function EncodeUser(UserName As String) As String
If Len(UserName) > 0 Then
Dim outstr As String
Dim DicStr As String
DicStr = "9012345678abcdeABCDEFGHIJKLMNfghijklmnUVWXYZxyzuvwopqrstOPQRST"
Dim DicA() As String
ReDim DicA(Len(DicStr) - 1)
Dim ff As Long
For ff = 0 To Len(DicStr) - 1
DicA(ff) = Mid(DicStr, ff + 1, 1)
Next
Dim DicB(15) As Byte
DicB(0) = &H11
DicB(1) = &H34
DicB(2) = &HC9
DicB(3) = &H23
DicB(4) = &H75
DicB(5) = &H18
DicB(6) = &HD7
DicB(7) = &HE2
DicB(8) = &H12
DicB(9) = &H35
DicB(10) = &H29
DicB(11) = &H2B
DicB(12) = &HEC
DicB(13) = &HB6
DicB(14) = &H23
DicB(15) = &H19
Dim inputstr As String
inputstr = "123456"
inputstr = UserName
Dim InputStrArray() As String
ReDim InputStrArray(Len(inputstr) - 1)
Dim OutPutArray() As String
ReDim OutPutArray(500)
For ff = 0 To Len(inputstr) - 1
InputStrArray(ff) = Mid(inputstr, ff + 1, 1)
Next
Dim i As Long
i = 0
Dim j As Long
j = 0
Dim num4 As Long: num4 = &H25
Dim di As Long
Dim var2 As Long
Dim index As Long
Dim var3 As Long: var3 = 0
For i = 0 To Len(inputstr) - 1
For j = 0 To Len(DicStr) - 1
If InputStrArray(i) = DicA(j) Then
If i >= &H10 Then
di = DicB(i Mod &H10)
Else
di = DicB(i)
End If
var2 = num4 * 3
index = (((di Xor var2) Xor var3) + j) Mod &H3E
OutPutArray(i) = DicA(index)
var2 = index
num4 = num4 Xor (var2 + &H24D9)
End If
Next j
If OutPutArray(i) = "" Then
OutPutArray(i) = InputStrArray(i)
End If
var3 = var3 + 5
Next i
Dim kk As Long
For kk = 0 To UBound(OutPutArray)
If OutPutArray(kk) <> "" Then
outstr = outstr + OutPutArray(kk)
End If
Next
outstr = "1:" + outstr
EncodeUser = outstr
Else
EncodeUser = UserName
End If
End Function
Private Sub mimasz1_Click()
If mimasz1.Value = True Then
mmyhmsw.Enabled = True
mima1.Enabled = False
symm = Right(dzhname, 6) 'symm = Right(dzhname, CInt(mmyhmsw.Text))
Else
mmyhmsw.Enabled = False
End If
End Sub
Private Sub mimasz2_Click()
If mimasz2.Value = True Then
mmyhmsw.Enabled = False
mima1.Enabled = True
symm = mima1.Text
Else
mmyhmsw.Enabled = False
End If
End Sub
Private Sub tingzhi_Click() '停止按钮
End Sub
Option Explicit
Private Const WS_VERSION_REQD As Long = &H101
Private Const INADDR_NONE As Long = &HFFFFFFFF
Private Const MAX_WSADescription As Long = 256
Private Const MAX_WSASYSStatus As Long = 128
Private Const PING_TIMEOUT As Long = 500
Private Type ICMP_OPTIONS
Ttl As Byte
Tos As Byte
Flags As Byte
OptionsSize As Byte
OptionsData As Long
End Type
Private Type ICMP_ECHO_REPLY
Address As Long
status As Long
RoundTripTime As Long
DataSize As Long
DataPointer As Long
Data As String * 250
End Type
Private Type WSADATA
wVersion As Integer
wHighVersion As Integer
szDescription(0 To MAX_WSADescription) As Byte
szSystemStatus(0 To MAX_WSASYSStatus) As Byte
wMaxSockets As Long
wMaxUDPDG As Long
dwVendorInfo As Long
End Type
Option Explicit
Private Const WS_VERSION_REQD As Long = &H101
Private Const INADDR_NONE As Long = &HFFFFFFFF
Private Const MAX_WSADescription As Long = 256
Private Const MAX_WSASYSStatus As Long = 128
Private Const PING_TIMEOUT As Long = 500
Private Type ICMP_OPTIONS
Ttl As Byte
Tos As Byte
Flags As Byte
OptionsSize As Byte
OptionsData As Long
End Type
Private Type ICMP_ECHO_REPLY
Address As Long
status As Long
RoundTripTime As Long
DataSize As Long
DataPointer As Long
Data As String * 250
End Type
Private Type WSADATA
wVersion As Integer
wHighVersion As Integer
szDescription(0 To MAX_WSADescription) As Byte
szSystemStatus(0 To MAX_WSASYSStatus) As Byte
wMaxSockets As Long
wMaxUDPDG As Long
dwVendorInfo As Long
End Type
'===============问题就出现在下面的源代码上,令我百思不得其解============
Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
Private Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal IcmpHandle As Long) As Long
Private Declare Function IcmpSendEcho Lib "icmp.dll" (ByVal IcmpHandle As Long, _
ByVal DestinationAddress As Long, ByVal RequestData As String, ByVal RequestSize As Long, _
ByVal RequestOptions As Long, ReplyBuffer As ICMP_ECHO_REPLY, ByVal ReplySize As Long, _
ByVal Timeout As Long) As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Long, _
lpWSADATA As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Declare Function gethostname Lib "WSOCK32.DLL" (ByVal szHost As String, _
ByVal dwHostLen As Long) As Long
Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal szHost As String) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(xDest As Any, xSource As Any, ByVal nbytes As Long)
Private Declare Function inet_addr Lib "WSOCK32.DLL" (ByVal s As String) As Long
[ 本帖最后由 swn2008 于 2011-8-20 21:22 编辑 ]