一道关于VB的排序法的编程题目求解!!!
发布网友
发布时间:2023-07-11 18:56
我来回答
共2个回答
热心网友
时间:2024-12-04 19:07
Private Sub Command1_Click()
lap1:
Randomize
temp = Int(Rnd() * 1000000 + 1)
If temp < 100000 Then GoTo lap1
Text1.Text = temp
strtemp = CStr(temp)
Text2.Text = ""
For i = 6 To 1 Step -1
Text2.Text = Text2.Text + Mid(strtemp, i, 1)
Next
End Sub
Private Sub Command2_Click()
Shell "notepad.exe", 1
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Command1.Caption = "随机整数倒序"
Command2.Caption = "启动记事本"
End Sub
热心网友
时间:2024-12-04 19:08
Private Sub Command1_Click()
Dim str1 As String, str2 As String, i As Integer, j As Integer
Text1.Text = lnstr(6)
str1 = Me.Text1.Text
str2 = ""
j = Len(str1)
For i = 1 To j
str2 = str2 & Right(str1, 1)
str1 = Left(str1, j - i)
Next
Text2 = str2
Open "c:\test.txt" For Output As #1
Print #1, str2
Close #1
End Sub
Private Sub Command2_Click()
Shell "notepad.exe " & "c:\test.txt", vbNormalFocus
End Sub
'生成随机字符
Function lnstr(nn As Integer) As String
N = nn
For i = 1 To N 'N是指定长度
Randomize
T = Int(Rnd() * 3)
Select Case T
Case 0
Randomize
r = r & Chr(Int(Rnd() * 25) + 65) '生成一个大写字母
Case 1
Randomize
r = r & Chr(Int(Rnd() * 25) + 97) '生成一个小写字母
Case 2
Randomize
r = r & Chr(Int(Rnd() * 9) + 48) '生成一个数字
End Select
Next i
lnstr = r
End Function