因为不知道你要的是整数还是小数我就先当整数做private sub command1_click()dim a as integerdim b as integer dim r(1 to 3) as integer dim i as integera=val(text1.text)b=val(text2.text)for i=1 to 3randomizeif a<b thenr(i)=int(rnd*(b-a+1)+a)elser(i)=int(rnd*(a-b+1)+b)endifnextlabel1.caption=str(a(1))label2.caption=str(a(2))label3.caption=str(a(3))end sub
text1和text2是否数值或太大之类的错误请自己添加,随便写了一个:Private Sub Command1_Click()Dim aa As StringDim i, j, bb, cc As LongIf Val(Text1) > Val(Text2) Thencc = Val(Text1) - Val(Text2)Elsecc = Val(Text2) - Val(Text1)End IfIf cc > 10 Thenbb = 1For j = 1 To Len(Format(cc, "0"))bb = bb * 10NextEnd IfRandomize Timeri = Int(Rnd() * bb) Mod ccIf Val(Text1) > Val(Text2) Theni = i + Val(Text2)Elsei = i + Val(Text1)End IfLabel1 = iRandomize Timeri = Int(Rnd() * bb) Mod ccIf Val(Text1) > Val(Text2) Theni = i + Val(Text2)Elsei = i + Val(Text1)End IfLabel2 = iRandomize Timeri = Int(Rnd() * bb) Mod ccIf Val(Text1) > Val(Text2) Theni = i + Val(Text2)Elsei = i + Val(Text1)End IfLabel3 = iEnd Sub