跳至正文

Vb格式里如何自动设置加减法,vb自加1

怎样在vb中使计算机随机给出两位数加减法算术题,并随时给出真确率

怎样在vb中使计算机随机给出两位数加减法算术题,并随时给出真确率

定义三个变量,比如:

int a[],w,jieguo;

//数组a的值是0-100的整数,w的值是加法还是减法,jieguo是最后的运算结果。

a[0]=(int)(Math.random()*100);

a[1]=(int)(Math.random()*100);

w=(string)(random(“+”,”-“));

if w=”+”

{jieguo=a[0]+a[1];

label1.text=(string)(a[0])+”+”+(string)(a[1])+”=”+(string)(jieguo)

}

else

{jieguo=a[0]-a[1];

label1.text=(string)(a[0])+”-“+(string)(a[1])+”=”+(string)(jieguo)

}

end if

方法很笨…………- -!

{求助}VB编程实现加减运算

{求助}VB编程实现加减运算

‘text1和text2放加数与被加数 ‘text3放运算符 Private Sub command1_click() Select Case Text3.Text Case "+" s = Val(Text1.Text) + Val(Text2.Text) Case "-" s = Val(Text1.Text) – Val(Text2.Text) Case "*" s = Val(Text1.Text) * Val(Text2.Text) Case "/" s = Val(Text1.Text) / Val(Text2.Text) End Select Text4.Text = s End Sub

VB中如何自动生成n个100以内加法题,并且每道题后面能够输入答案?

VB中如何自动生成n个100以内加法题,并且每道题后面能够输入答案?

‘一个text1,2个Command1 ,text1设置成多行显示

Private Sub Command1_Click()

Dim i As Integer, k As Integer

Dim s1 As String, s2 As String

Randomize Time()

Text1.Text = “”

s1 = “”

For k = 1 To 30

s2 = Int(Rnd * (101))

s1 = s1 & s2 & ” + ” & Int(Rnd * (101)) & ” = ” & vbCrLf

Next

Text1.Text = s1

End Sub

Private Sub Command2_Click()

Dim slin As Variant, sj As Variant, s1 As String, s2 As String

Dim t1 As Integer, t2 As Integer, l As Integer, i As Integer

s1 = Trim(Text1.Text)

If s1 <> “” Then

If InStr(1, s1, vbCrLf) > 0 Then

slin = Split(s1, vbCrLf)

End If

For i = 0 To UBound(slin) – 1

sj = Split(slin(i), ” “)

t1 = Val(sj(0)) + Val(sj(2))

t2 = Val(Trim(Mid(slin(i), InStr(1, slin(i), “=”) + 1, 4)))

If t1 = t2 Then

s2 = s2 & slin(i) & ” 对” & vbCrLf

Else

s2 = s2 & slin(i) & ” 错” & vbCrLf

End If

Next

Text1.Text = s2

End If

End Sub

VB6文本框内自动加法运算

急也不加点分,

Private Sub XX()

On Error GoTo Wro:

Dim a As Integer, b As Integer

For i = 1 To Len(Text1.Text)

Select Case Mid(Text1.Text, i, 1)

Case “+”

a = i

b = 1

Case “-“

a = i

b = 2

Case “*”

a = i

b = 3

Case “/”

a = i

b = 4

End Select

Next

If IsNumeric(Left(Text1.Text, a – 1)) = True And IsNumeric(Right(Text1.Text, Len(Text1.Text) – a)) = True Then

Select Case b

Case 1

Text1.Text = Text1.Text & “=” & CSng(Left(Text1.Text, a – 1)) + CSng(Right(Text1.Text, Len(Text1.Text) – a))

Case 2

Text1.Text = Text1.Text & “=” & CSng(Left(Text1.Text, a – 1)) – CSng(Right(Text1.Text, Len(Text1.Text) – a))

Case 3

Text1.Text = Text1.Text & “=” & CSng(Left(Text1.Text, a – 1)) * CSng(Right(Text1.Text, Len(Text1.Text) – a))

Case 4

Text1.Text = Text1.Text & “=” & CSng(Left(Text1.Text, a – 1)) / CSng(Right(Text1.Text, Len(Text1.Text) – a))

End Select

End If

Exit Sub

Wro:

End Sub

Private Sub form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If X < Text1.Left Or X > (Text1.Left + Text1.Width) Or Y < Text1.Top Or Y > (Text1.Top + Text1.Height) Then XX

End Sub

vb中加法是怎么实现的呢?

Text3.Text = Text1.Text + Text2.Text 是字符串相加,结果就是把两个字符串连起来.正确应该是 Text3.Text = val(Text1.Text) +val(Text2.Text) 注意:+运算在VB中有两种定义,一个是正常的加法,一个是字符串相连.VB会自动根据情况选择,Text3.Text 是字符串,因此VB自动选择第二种定义来算.但-和*运算只有一种定义,那就是数字相差和相乘,因此VB会自动把Text3.Text 转换成数字运行运算.

VB怎么编制加减运算程序

创建text1、text2、command1、command2、command3、command4代码如下Private Sub Form_Load()

Text1.Text = “”

Text2.Text = “”

Command1.Caption = “+”

Command2.Caption = “-“

Command3.Caption = “*”

Command4.Caption = “/”

End Sub

Private Sub Command1_Click()

s = Val(Text1.Text) + Val(Text2.Text)

MsgBox Text1.Text & ” + ” & Text2.Text & ” = ” & Str(s)

End SubPrivate Sub Command2_Click()

s = Val(Text1.Text) – Val(Text2.Text)

MsgBox Text1.Text & ” – ” & Text2.Text & ” = ” & Str(s)

End SubPrivate Sub Command3_Click()

s = Val(Text1.Text) * Val(Text2.Text)

MsgBox Text1.Text & ” * ” & Text2.Text & ” = ” & Str(s)

End SubPrivate Sub Command4_Click()

s = Val(Text1.Text) / Val(Text2.Text)

MsgBox Text1.Text & ” / ” & Text2.Text & ” = ” & Str(s)

End Sub

Private Sub Text1_lostfocus()

If Text1.Text = “” Then MsgBox “输入第一个数值”

End SubPrivate Sub Text2_lostfocus()

If Text2.Text = “” Then MsgBox “输入第二个数值”

If Text2.Text = “0” Then

MsgBox “除数不能为0”

Text2.SetFocus

End If

End Sub

怎么VB加法实现功能?

用Excel和不用Excel都可以做,

1、不用Excel的,Text1、Text2、Text3输入,Text4输出

Private Sub Text1_Change()

Text4.Text = CStr(CSng(Text1.Text) + CSng(Text2.Text) + CSng(Text3.Text))

End Sub

Private Sub Text2_Change()

Text4.Text = CStr(CSng(Text1.Text) + CSng(Text2.Text) + CSng(Text3.Text))

End Sub

Private Sub Text3_Change()

Text4.Text = CStr(CSng(Text1.Text) + CSng(Text2.Text) + CSng(Text3.Text))

End Sub

2、用Excel做的话,请加分,给代码你!

在VB 中怎样出现随机加减号

产生随机加减号容易: Function rndjj() As Integer rndjj = IIf(Rnd() > 0.5, 1, -1) End Function 掌握vb的随机函数 rnd() 就ok了

vb 如何实现字符型和整形的加减法

期待看到有用的回答!

VB 文字框怎样用键盘控制数字加减?

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 38 Then Text1 = Val(Text1) + 1 If KeyCode = 40 Then Text1 = Val(Text1) – 1 End Sub