VB随即四则运算程序的一些问题(急用!谢)[请求]

小小破米

新手上路
注册
2006-03-12
消息
13
荣誉分数
0
声望点数
0
请教:如何编写一个随机显示四则运算的vb程序?
首先,随机显示的+,-,*,/怎样作为运算符号出现?
改用什马语法编辑呢?
其次,最后的正确答案dblAnswer = intNumber1.....intNumber2
中间该怎样和那些运算符号连接起来,酸楚每次随机题的得数呢?
谢谢了。。。。真的很急
 
getText()
if (test == '+') dblAnswer = intNumber1 + intNumber2
else if(test == '-')
else if(test == '*')
else
 
并不难吗!
把它们当做 字符去打印就行了。
 
那个code是你写的阿,他还把code发给我,让我给看看
月下你没被trusted啊
你的代码ei
Private Sub cmdNew_Click()
intNum1 = Int(10 * Rnd + 1)
intNum2 = Int(10 * Rnd + 1)
strSign = Rnd(1 - 4)
Select Case strSign
Case "+"
Case "-"
Case "*"
Case "/"

If strSign = "+" Then
dblAnswer = intNum1 + intNum2
ElseIf strSign = "-" Then
dblAnswer = intNum1 - intNum2
ElseIf strSign = "*" Then
dblAnswer = intNum1 * intNum2
ElseIf strSign = "/" Then
dblAnswer = intNum1 / intNum2
End If
End Select
lblNum1.Caption = intNum1
lblNum2.Caption = intNum2
lblSign.Caption = strSign
 
这个不是偶给的代码,有很大区别阿

我说的

first rnd a number between 1-4

then case numer:
for each number assign a *,/,- or +

then do if/elsif based on the case...

手上没有editor没有给出exact code而已阿。。。

或者直接在case里做了就是了。。
 
楼主做人过分了。
我给了两次Pseudocode了

满意了吧?!

Dim intRnd, intOne, intTwo As Integer
Dim intOut As Double

Randomize
intRnd = Int((4) * Rnd + 1)

Select Case intRnd
Case 1:
intOut = intOne + intTwo
Case 2:
intOut = intOne - intTwo
Case 3:
intOut = intOne * intTwo
Case 4:
intOut = intOne / intOut
End Select

:flaming:
 
不要生气啦~~

喂喂喂~~~不要生气好不好啊?怎马能跟个小女孩一般见识呢~~是不?
嗬嗬,问题解决了~~多谢你们了,你们都是我的英雄,嘻嘻~~~
 
后退
顶部