VB高手请进!!!

2024-12-16 04:12:40
推荐回答(5个)
回答1:

借助LBound函数可以得到数组的元素下限值,实际上,在定义时写dim
a(10),其下标从0-9;写为dim
a(1
to
10),下标从1-10。

回答2:

这个其实不难,如果你学过的话就简单了,只要你连接好了数据库多定义几个变量计数就行了,当点击按钮的时候进行下运算对数据库的数值进行更新,最后读取就是你想要的了!人要靠自己!这个程序确实是要花钱的,除非从网上能找到,但一般不会有人向网上传这些代码!

回答3:

程序代码如下:
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

以上程序应该能够解决你的问题。

回答4:

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

回答5:

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 strnext i

'下面是打印
for i=0 to 9
print a(i)
next i
print "最大的是" & chr(max)
print "最小的是" & chr(min)

回答者: shalyun - 江湖新秀 四级 2009-6-5 13:23