'2、寫一程式計算一組數字的乘積。你的程式必須再讀入0時停止,若讀入非0的
' 資料時,則予以計算乘積。
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <> 0 Then
If TextBox2.Text <> 0 Then
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
Label3.Text = ""
Else
Label3.Text = "停止計算"
TextBox3.Clear()
End If
ElseIf TextBox1.Text = 0 Then
Label3.Text = "停止計算"
TextBox3.Clear()
End If
End Sub
End Class
我也給個參考答案吧!
回覆刪除jack
If TextBox1.Text <> 0 And TextBox2.Text <> 0 Then
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
Label3.Text = ""
Else
Label3.Text = "停止計算"
TextBox3.Clear()
End If