首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

比较多个变量名的最小值?该如何解决

2012-02-14 
比较多个变量名的最小值??在之前的过程中,多个变量名已经赋值了。现在要比较出少最小的变量名?多个变量名,

比较多个变量名的最小值??
在之前的过程中,多个变量名已经赋值了。
现在要比较出少最小的变量名?

多个变量名,为:
a,b,c,d,e,f,g,七个数。

请写出代码来,谢谢!


[解决办法]
min = a : vmin = "a"
if b < min then min = b : vmin = "b"
if c < min then min = c : vmin = "c"
if d < min then min = d : vmin = "d"
if e < min then min = e : vmin = "e"
if f < min then min = f : vmin = "f"
if g < min then min = g : vmin = "g"
[解决办法]

VB code
Private Sub Command1_Click()   Dim n(6), i As Integer   n(0) = a: n(1) = b: n(2) = c   n(3) = d: n(4) = e: n(5) = f: n(6) = g   For i = 0 To 6       If n(0) > n(i) Then n(0) = n(i)   Next   MsgBox n(0)End Sub
[解决办法]
VB code
Private Sub Command1_Click()   Dim n(6), i As Integer   n(0) = a: n(1) = b: n(2) = c   n(3) = d: n(4) = e: n(5) = f: n(6) = g   For i = 1 To 6       If n(0) > n(i) Then n(0) = n(i)   Next   MsgBox n(0)End Sub 

热点排行