Quantcast
Channel: 神魂顛倒論壇-Flash--Visual Basic .Net 討論最新50篇論壇主題-全文
Viewing all articles
Browse latest Browse all 74

個位會寫vb高手的大大 我想請教一下?

$
0
0

我們老師出問題 想辦法讓最後變 = 號 我想了很久 都試不出來~

可不可以幫忙一下

因為假如我給數字是 5 就會等於 1+3+5+9 要怎麼才會1+3+5=9

老師只提是 用 if 做我們班的人想了很久我自己也試了很久弄不出個所以然拜託幫忙一下 感激~

如果可以的話麻煩可以方便說明一下 你用的如果的意思 謝謝

Private Sub Command1_Click()
inp = Val(Text1.Text)
If inp > 21 Or inp < 5 Then
ret = MsgBox("請輸入5~21的整數", 16, "錯誤訊息")
Text1.Text = ""
Text1.SetFocus
Else
If inp Mod 2 = 1 Then
ini = 1
Else
ini = 2
End If
total = 0
For i = ini To inp Step 2
total = total + i
str1 = str1 & i & " + "
Next

lblout.Caption = str1 & total
End If
End Sub


Private Sub Command2_Click()
End
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
ret = MsgBox("輸入必須為數值", 16, "錯誤訊息")
KeyAscii = 13
Text1.Text = ""
End If
End Sub

在新視窗檢視

Viewing all articles
Browse latest Browse all 74

Trending Articles