VB高手请进!!!
随机产生10个不重复的A-Z(包括A和Z)的大写字母,放在字符数组中,并求出最大的字符和最小的字符,要求将10个字符,最大和最小的字符输出在窗体上....
随机产生10个不重复的A-Z(包括A和Z)的大写字母,放在字符数组中,并求出最大的字符和最小的字符,要求将10个字符,最大和最小的字符输出在窗体上.
展开
9个回答
展开全部
借助LBound函数可以得到数组的元素下限值,实际上,在定义时写dim
a(10),其下标从0-9;写为dim
a(1
to
10),下标从1-10。
a(10),其下标从0-9;写为dim
a(1
to
10),下标从1-10。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
这个其实不难,如果你学过的话就简单了,只要你连接好了数据库多定义几个变量计数就行了,当点击按钮的时候进行下运算对数据库的数值进行更新,最后读取就是你想要的了!人要靠自己!这个程序确实是要花钱的,除非从网上能找到,但一般不会有人向网上传这些代码!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
程序代码如下:
Private Sub Form_Click()
Cls
Dim a(9) As String, n%
Randomize
a(0) = Chr(Int(Rnd * 26 + 65))
n = 1
Do While n <= 9
y = 0
c = Chr(Int(Rnd * 26 + 65))
For j = 0 To n - 1
If a(j) = c Then y = 1: Exit For
Next j
If y = 0 Then a(n) = c: n = n + 1
Loop
For i = 0 To 9
Print a(i) & ",";
If (i + 1) Mod 5 = 0 Then Print
Next i
Min = a(0): imin = 0
For i = 0 To 9 '求最小值的数组
If a(i) < Min Then Min = a(i): imin = i
Next i
Print "最小的字符为:" & a(imin)
Max = a(0): imax = 0
For i = 0 To 9 '求最大值的数组
If a(i) > Max Then Max = a(i): imax = i
Next i
Print "最大的字符为:" & a(imax)
End Sub
以上程序应该能够解决你的问题。
Private Sub Form_Click()
Cls
Dim a(9) As String, n%
Randomize
a(0) = Chr(Int(Rnd * 26 + 65))
n = 1
Do While n <= 9
y = 0
c = Chr(Int(Rnd * 26 + 65))
For j = 0 To n - 1
If a(j) = c Then y = 1: Exit For
Next j
If y = 0 Then a(n) = c: n = n + 1
Loop
For i = 0 To 9
Print a(i) & ",";
If (i + 1) Mod 5 = 0 Then Print
Next i
Min = a(0): imin = 0
For i = 0 To 9 '求最小值的数组
If a(i) < Min Then Min = a(i): imin = i
Next i
Print "最小的字符为:" & a(imin)
Max = a(0): imax = 0
For i = 0 To 9 '求最大值的数组
If a(i) > Max Then Max = a(i): imax = i
Next i
Print "最大的字符为:" & a(imax)
End Sub
以上程序应该能够解决你的问题。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub Find_Chr()
Dim ArrChr(1 To 10) As String
Dim LowChr As String
Dim UpChr As String
Dim ChrLen As Integer
Randomize
LowChr = "A"'最小字符
UpChr = "Z"'最大字符
ChrLen = Asc(UpChr) - Asc(LowChr) + 1'范围跨度+1
For i = 1 To 10
1000:
ArrChr(i) = Chr(Int(ChrLen * Rnd) + Asc(LowChr))
For j = 1 To i - 1
If ArrChr(i) < ArrChr(j) Then
k = ArrChr(i)
ArrChr(i) = ArrChr(j)
ArrChr(j) = k
Else: If ArrChr(i) = ArrChr(j) Then GoTo 1000'如果有重复字符则重新取
End If
Next
Next
'打印
For n = 1 To 10
Print ArrChr(n)
Next
Print "最小字符" & ArrChr(1)
Print "最大字符" & ArrChr(10)
End Sub
Dim ArrChr(1 To 10) As String
Dim LowChr As String
Dim UpChr As String
Dim ChrLen As Integer
Randomize
LowChr = "A"'最小字符
UpChr = "Z"'最大字符
ChrLen = Asc(UpChr) - Asc(LowChr) + 1'范围跨度+1
For i = 1 To 10
1000:
ArrChr(i) = Chr(Int(ChrLen * Rnd) + Asc(LowChr))
For j = 1 To i - 1
If ArrChr(i) < ArrChr(j) Then
k = ArrChr(i)
ArrChr(i) = ArrChr(j)
ArrChr(j) = k
Else: If ArrChr(i) = ArrChr(j) Then GoTo 1000'如果有重复字符则重新取
End If
Next
Next
'打印
For n = 1 To 10
Print ArrChr(n)
Next
Print "最小字符" & ArrChr(1)
Print "最大字符" & ArrChr(10)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim a(0 to 9) as string
dim str
dim max =65
dim min=90
for i = 0 to 9
str=int(rnd *26)+65
a(i)=chr(str)
if str>max then max= str
if str<min then min=str
next i
'下面是打印
for i=0 to 9
print a(i)
next i
print "最大的是" & chr(max)
print "最小的是" & chr(min)
回答者: shalyun - 江湖新秀 四级 2009-6-5 13:23
dim str
dim max =65
dim min=90
for i = 0 to 9
str=int(rnd *26)+65
a(i)=chr(str)
if str>max then max= str
if str<min then min=str
next i
'下面是打印
for i=0 to 9
print a(i)
next i
print "最大的是" & chr(max)
print "最小的是" & chr(min)
回答者: shalyun - 江湖新秀 四级 2009-6-5 13:23
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询