Private Sub Form_Click()
x = Val(Right(Text1Text, 2)) '取学号末2位
'以下是加密
s = Text2Text
s1 = s
For i = 1 To Len(s)
c = Mid(s1, i, 1)
Mid(s1, i, 1) = Chr(Asc(c) Xor x)
Next i
Text3Text = s1
'以下是解密
s = s1
For i = 1 To Len(s)
c = Mid(s, i, 1)
Mid(s, i, 1) = Chr(Asc(c) Xor x)
Next i
Text4Text = s
End Sub
'用法:: AA "1234"
Function AA(ByVal x As String) As String
Dim ns As Integer
ns = Len(x)
Dim n() As String
Dim w() As Integer
ReDim n(ns)
ReDim w(ns)
Dim i As Integer
For i = 1 To ns
n(i) = Mid(x, ns - i + 1, 1)
Next
Dim str As String
BB n, w, 0, str
MsgBox str
Open "c:\1txt" For Output As #1 ''输出文件句自己改
Print #1, str
Close #1
End Function
Function BB(ByRef n() As String, w() As Integer, ByVal k As Integer, s As String)
Dim i As Integer, j As Integer
Dim b As Boolean
For i = 1 To UBound(n)
b = False
For j = 1 To k
If i = w(j) Then
b = True
Exit For
End If
Next
If Not b And k + 1 <= UBound(n) Then
w(k + 1) = i
BB n, w, k + 1, s
End If
Next
If UBound(w) = k Then
For i = 1 To UBound(w)
s = s & n(w(i))
Next
s = s & vbCrLf
Exit Function
End If
End Function
Private Sub form_click()
MeShow
m = 10
n = 1
Print Int(Rnd (m - n - 1) + n + 1)
End Sub
第二题
Private Sub Form_Load()
Timer1Enabled = True
Timer1Interval = 1000
End Sub
Private Sub Timer1_Timer()
Cls
Print Format(Now, "long date") & " " & Time
End Sub
程序包含一个标签和一个间隔1秒的时间控件
Private xx(1 To 5) As String
Private i As Integer, f As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 112 Then
f = MsgBox("你按了F1,继续吗?", vbYesNo + vbInformation, "提示")
If f = vbYes Then
Timer1Enabled = True
Else
Call Form_KeyDown(113, 0)
End If
ElseIf KeyCode = 113 Then
MsgBox "你按了F2键,结束应用程序!"
End
End If
End Sub
Private Sub Form_Load()
xx(1) = "aaaaaaaaaa"
xx(2) = "bbbbbbbbbb"
xx(3) = "cccccccccc"
xx(4) = "dddddddddd"
xx(5) = "请按F1、F2"
i = 1
End Sub
Private Sub Timer1_Timer()
Label1Caption = xx(i)
If xx(i) = "请按F1、F2" Then
Timer1Enabled = False
Call Form_KeyDown(112, 0)
End If
i = i + 1
If i > 5 Then i = 1
End Sub
你也可以手动按F1、F2 效果一样!
form1上放置Command1,Timer1,Picture1(装入一个)
Dim MoveStep As Integer
Private Sub Command1_Click()
Timer1Enabled = False
End Sub
Private Sub Form_Load()
MoveStep = 100
End Sub
Private Sub Timer1_Timer()
If Picture1Left + Picture1Width + 30 > Form1Width Then
MoveStep = -100
End If
If Picture1Left < 0 Then
MoveStep = 100
End If
Picture1Left = Picture1Left + MoveStep
End Sub
以上就是关于Vb编程编写一个小程序,可以对输入的一段英文字符串进行加密和解密,加密算法中需要使用到学号后两位全部的内容,包括:Vb编程编写一个小程序,可以对输入的一段英文字符串进行加密和解密,加密算法中需要使用到学号后两位、如何用VB编写一个生成文本的小程序、用VB写个小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)