哭求VB程序修改题目
3..编写程序,使得其能对输入的任意数判断是否为回文数,要求每输入一次就进行一次判断,并在图形框中显示,若是回文数,在该数后加一个"★"所谓回文数就是指该数顺读和倒读都相...
3.. 编写程序,使得其能对输入的任意数判断是否为回文数,要求每输入一次就进行一次判断,并在图形框中显示,若是回文数,在该数后加一个"★"
所谓回文数就是指该数顺读和倒读都相同,比如141, 12321这样的数
121★
147
12321★
159
代码如下:Private Function HuiWen(S As String) As Integer
Dim l As Integer, i As Integer
l = Len(S)
HuiWen = 1
For i = 1 To Int(l / 2)
'下行有错
If Mid$(S, i, 1) <> Mid$(S, l - i, 1) Then HuiWen = 0: Exit For
Next i
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'下行有错
If HuiWen(Text1.Text) = 0 Then
Picture1.Print Text1.Text; "★"
Else
Picture1.Print Text1.Text
End If
Text1.Text = ""
End If
End Sub
4...编一程序由计算机产生中奖号,规定每十万张为一组,共5组,用A B C D E表示不同的组.中奖号码为一个5位数码,前面加组号,如B12547表示B的中奖号,规定每组产生5个中奖号且不重号.
代码如下:Private Sub Command1_Click()
Dim zj(20, 20) As String
Text1.Text = ""
For i = 1 To 5
j = 1
While j <= Val(Text2.Text)
zj(i, j) = Chr(64 + i)
zj1 = Int(Rnd * 9) + 1
zj2 = Int(Rnd * 9 + 1)
zj3 = Int(Rnd * 9 + 1)
zj4 = Int(Rnd * 9 + 1)
zj5 = Int(Rnd * 9 + 1)
'下行有错
zjhm = zj(i, j) + zj1 + zj2 + zj3 + zj4 + zj5
For k = 1 To j - 1
If zjhm = zj(i, k) Then Exit For
Next k
If k = j Then zj(i, j) = zjhm
j = j + 1
Wend
Next i
For i = 1 To 5
'下行有错
For j = 1 To i
Text1.Text = Text1.Text + zj(i, j) + " "
Next j
Text1.Text = Text1.Text + Chr(13) + Chr(10)
Next i
End Sub 展开
所谓回文数就是指该数顺读和倒读都相同,比如141, 12321这样的数
121★
147
12321★
159
代码如下:Private Function HuiWen(S As String) As Integer
Dim l As Integer, i As Integer
l = Len(S)
HuiWen = 1
For i = 1 To Int(l / 2)
'下行有错
If Mid$(S, i, 1) <> Mid$(S, l - i, 1) Then HuiWen = 0: Exit For
Next i
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'下行有错
If HuiWen(Text1.Text) = 0 Then
Picture1.Print Text1.Text; "★"
Else
Picture1.Print Text1.Text
End If
Text1.Text = ""
End If
End Sub
4...编一程序由计算机产生中奖号,规定每十万张为一组,共5组,用A B C D E表示不同的组.中奖号码为一个5位数码,前面加组号,如B12547表示B的中奖号,规定每组产生5个中奖号且不重号.
代码如下:Private Sub Command1_Click()
Dim zj(20, 20) As String
Text1.Text = ""
For i = 1 To 5
j = 1
While j <= Val(Text2.Text)
zj(i, j) = Chr(64 + i)
zj1 = Int(Rnd * 9) + 1
zj2 = Int(Rnd * 9 + 1)
zj3 = Int(Rnd * 9 + 1)
zj4 = Int(Rnd * 9 + 1)
zj5 = Int(Rnd * 9 + 1)
'下行有错
zjhm = zj(i, j) + zj1 + zj2 + zj3 + zj4 + zj5
For k = 1 To j - 1
If zjhm = zj(i, k) Then Exit For
Next k
If k = j Then zj(i, j) = zjhm
j = j + 1
Wend
Next i
For i = 1 To 5
'下行有错
For j = 1 To i
Text1.Text = Text1.Text + zj(i, j) + " "
Next j
Text1.Text = Text1.Text + Chr(13) + Chr(10)
Next i
End Sub 展开
1个回答
展开全部
3、
Private Function HuiWen(S As String) As Boolean'不要用整形,是否的判断是布尔型
Dim l As Integer, i As Integer
l = Len(S)
HuiWen = True
For i = 1 To Int(l / 2)
If Mid$(S, i, 1) <> Mid$(S, l - i + 1, 1) Then HuiWen = False: Exit For'当i=1时,l-i不是最后一个,而是倒数第二,故要+1
Next i
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If HuiWen(Text1.Text) Then
Picture1.Print Text1.Text; "★"
Else
Picture1.Print Text1.Text
End If
Text1.Text = ""
End If
End Sub
4、
Private Sub Command1_Click()
Dim zj(20, 20) As String
Text1.Text = ""
For i = 1 To 5
j = 1
While j <= Val(Text2.Text)
zj(i, j) = Chr(64 + i)
zj1 = Int(Rnd * 9) + 1
zj2 = Int(Rnd * 9 + 1)
zj3 = Int(Rnd * 9 + 1)
zj4 = Int(Rnd * 9 + 1)
zj5 = Int(Rnd * 9 + 1)
zjhm = zj(i, j) & zj1 & zj2 & zj3 & zj4 & zj5 '字符不能和数字相加
For k = 1 To j - 1
If zjhm = zj(i, k) Then Exit For
Next k
If k = j Then zj(i, j) = zjhm
j = j + 1
Wend
Next i
For i = 1 To 5 '这里没有错误
For j = 1 To i
Text1.Text = Text1.Text + zj(i, j) + " "
Next j
Text1.Text = Text1.Text + Chr(13) + Chr(10)
Next i
End Sub
Private Function HuiWen(S As String) As Boolean'不要用整形,是否的判断是布尔型
Dim l As Integer, i As Integer
l = Len(S)
HuiWen = True
For i = 1 To Int(l / 2)
If Mid$(S, i, 1) <> Mid$(S, l - i + 1, 1) Then HuiWen = False: Exit For'当i=1时,l-i不是最后一个,而是倒数第二,故要+1
Next i
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If HuiWen(Text1.Text) Then
Picture1.Print Text1.Text; "★"
Else
Picture1.Print Text1.Text
End If
Text1.Text = ""
End If
End Sub
4、
Private Sub Command1_Click()
Dim zj(20, 20) As String
Text1.Text = ""
For i = 1 To 5
j = 1
While j <= Val(Text2.Text)
zj(i, j) = Chr(64 + i)
zj1 = Int(Rnd * 9) + 1
zj2 = Int(Rnd * 9 + 1)
zj3 = Int(Rnd * 9 + 1)
zj4 = Int(Rnd * 9 + 1)
zj5 = Int(Rnd * 9 + 1)
zjhm = zj(i, j) & zj1 & zj2 & zj3 & zj4 & zj5 '字符不能和数字相加
For k = 1 To j - 1
If zjhm = zj(i, k) Then Exit For
Next k
If k = j Then zj(i, j) = zjhm
j = j + 1
Wend
Next i
For i = 1 To 5 '这里没有错误
For j = 1 To i
Text1.Text = Text1.Text + zj(i, j) + " "
Next j
Text1.Text = Text1.Text + Chr(13) + Chr(10)
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询