| 一个VB程序的修改,谢谢谢谢
|
减小字体
增大字体
|
问题:Option Base 1Dim key(26) As String Private Sub Command1_Click() If Option1.Value Then m = Text2.Text: n = Text1.Text Call keys(m, n) Text3.Text = keys(m, n) ElseIf Option2.Value Then x = Text2.Text: y = Text3.Text Call okeys(x, y) Text1.Text = okeys(x, y) Else Dim sorry As Integer sorry = MsgBox(请选择加密或解密, vbExclamation, sorry) End If End Sub Public Function okey(x As String) As Integer Dim i As Integer For i = 1 To 26 If key(i) = x Then okey = i Next iEnd FunctionPrivate Sub Form_Load() key(1) = a: key(2) = b: key(3) = c: key(4) = d: key(5) = e: key(6) = f: key(7) = g: key(8) = h key(9) = i: key(10) = j: key(11) = k: key(12) = l: key(13) = m: key(14) = n: key(15) = o: key(16) = p key(17) = q: key(18) = r: key(19) = s: key(20) = t: key(21) = u: key(22) = v: key(23) = w: key(24) = x key(25) = y: key(26) = zEnd SubPublic Function keys(m, n As String) As String Dim i As Integer Dim A() As Integer ReDim A(Len(m)) As Integer For i = 1 To Len(m) Call okey(Mid(m, i, 1)) A(i) = okey(Mid(m, i, 1)) Next i Dim B() As Integer ReDim B(Len(n)) As Integer Dim f As Integer For f = 1 To Len(n) Dim g As Integer If f Mod Len(m) <> 0 Then g = f Mod Len(m) ElseIf f Mod Len(m) = o Then g = Len(m) End If Call okey(Mid(n, f, 1)) B(f) = okey(Mid(n, f, 1)) + A(g) Next f Dim C As String For f = 1 To Len(n) Dim h As Integer If B(f) Mod 26 <> 0 Then h = B(f) Mod 26 ElseIf B(f) Mod 26 = 0 Then h = 26 End If C = C + key(h) Next f keys = CEnd FunctionPublic Function okeys(x, y) As Integer Dim z As String If keys(x, z) = y Then okeys = z End Function为什么运行的时候是ByRef 参数类型不匹配呢
Public Function okey(x As String) As Integer 改为 Public Function okey(byval x As String) As Integer
Public Function okeys(x, y) As Integer 改为 Public Function okeys(byval x, byval y) As Integer
因为Command1_Click中的x y未定义数据类型 如果你对Option Base 1Dim key(26) As String Private Sub Command1_Click() If Option1.Value Then m = Text2.Text: n = Text1.Text Call keys(m, n) Text3.Text = keys(m, n) ElseIf Option2.Value Then x = Text2.Text: y = Text3.Text Call okeys(x, y) Text1.Text = okeys(x, y) Else Dim sorry As Integer sorry = MsgBox(请选择加密或解密, vbExclamation, sorry) End If End Sub Public Function okey(x As String) As Integer Dim i As Integer For i = 1 To 26 If key(i) = x Then okey = i Next iEnd FunctionPrivate Sub Form_Load() key(1) = a: key(2) = b: key(3) = c: key(4) = d: key(5) = e: key(6) = f: key(7) = g: key(8) = h key(9) = i: key(10) = j: key(11) = k: key(12) = l: key(13) = m: key(14) = n: key(15) = o: key(16) = p key(17) = q: key(18) = r: key(19) = s: key(20) = t: key(21) = u: key(22) = v: key(23) = w: key(24) = x key(25) = y: key(26) = zEnd SubPublic Function keys(m, n As String) As String Dim i As Integer Dim A() As Integer ReDim A(Len(m)) As Integer For i = 1 To Len(m) Call okey(Mid(m, i, 1)) A(i) = okey(Mid(m, i, 1)) Next i Dim B() As Integer ReDim B(Len(n)) As Integer Dim f As Integer For f = 1 To Len(n) Dim g As Integer If f Mod Len(m) <> 0 Then g = f Mod Len(m) ElseIf f Mod Len(m) = o Then g = Len(m) End If Call okey(Mid(n, f, 1)) B(f) = okey(Mid(n, f, 1)) + A(g) Next f Dim C As String For f = 1 To Len(n) Dim h As Integer If B(f) Mod 26 <> 0 Then h = B(f) Mod 26 ElseIf B(f) Mod 26 = 0 Then h = 26 End If C = C + key(h) Next f keys = CEnd FunctionPublic Function okeys(x, y) As Integer Dim z As String If keys(x, z) = y Then okeys = z End Function为什么运行的时候是ByRef 参数类型不匹配呢这个问题有好的意见或
建议,请留言
|
|
[]
[返回上一页]
[打 印]
|
|
|