Vb11.12 VB 中基本語句
1.If
































































Do loop 的另一種形式
Do
s=s+i
i=i+1
Loop while i<=b



do until 當條件不滿足時候執行
Do
s=s+i
i=i+1
Loop until i>b
7.While...(條件滿足時) Wend(執行)


























posted @ 2010-11-12 16:30 Herose 閱讀(113) | 評論 (0) | 編輯 收藏
Herose
posted @ 2010-11-12 16:30 Herose 閱讀(113) | 評論 (0) | 編輯 收藏
posted @ 2010-11-11 17:46 Herose 閱讀(85) | 評論 (0) | 編輯 收藏
1.
Dim a As Double
Private Sub Command1_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Fix(a) "取整"
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Int(a) "不大于數值(456.123)的整數部分"
End Sub
Private Sub Command3_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Abs(a) "絕對值"
End Sub
Private Sub Command4_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Sgn(a) "判斷數值為正數(1)負數(-1)0(0)"
End Sub
Private Sub Command5_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Sqr(a) "平方根"
End Sub
Dim a As Integer
Private Sub Command1_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Log(a) "對數"
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text) "將字符串轉為數值"
MsgBox "函數值為:" & Sin(a) "正弦"
End Sub
Private Sub Command3_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Cos(a) "余弦"
End Sub
Private Sub Command4_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Tan(a) "正切"
End Sub
Private Sub Command5_Click()
a = Val(Text1.Text)
MsgBox "函數值為:" & Atn(a) "余切"
End Sub
posted @ 2010-11-11 15:03 Herose 閱讀(103) | 評論 (0) | 編輯 收藏
Dim a As String
Private Sub Form_Click()
Form1.Print a
End Sub
Private Sub Form_Load()
a = "這是窗體事件"
End Sub
Dim a As Integer
Private Sub Form_Click()
a = a + 1
Cls
Print "這是第" & a & "次說愛你"
End Sub
Dim a As Integer
Private Sub Form_Click()
form2.show 1/0
End Sub
posted @ 2010-11-10 18:05 Herose 閱讀(109) | 評論 (0) | 編輯 收藏
Private Sub Command1_Click()
Dim birthday As String
birthday = InputBox("輸入生日", "birthday", "1987-07-20")
MsgBox "您的生日是" & birthday
End Sub
Private Sub Command1_Click()
Form1.FontBold = True
Print "這是粗體"
End Sub
Private Sub Command2_Click()
Form1.FontItalic = True
Form1.FontBold = False
Print "這是斜體"
End Sub
Private Sub Command3_Click()
Form1.FontUnderline = True
Form1.FontItalic = False
Print "這是帶下劃線的"
End Sub
Private Sub Command4_Click()
Form1.FontStrikethru = True
Form1.FontUnderline = False
Print "這是帶刪除線的"
End Sub
posted @ 2010-11-10 16:59 Herose 閱讀(101) | 評論 (0) | 編輯 收藏
Private Sub Command1_Click()
Dim a, b As Double
a = Rnd
b = Rnd
If a > b Then
MsgBox "小弟帥的掉渣"
ElseIf a < b Then
MsgBox "小張帥的一塌糊涂"
Else
MsgBox "他們都不帥"
End If
End Sub
posted @ 2010-11-10 15:53 Herose 閱讀(92) | 評論 (0) | 編輯 收藏
Private Sub Command1_Click()
Form1.Text1.FontBold = True
End Sub
Private Sub Command2_Click()
Form1.Text1.FontItalic = True
Form1.Text1.FontUnderline = True
End Sub
Private Sub Command3_Click()
Form1.Width = Form1.Width + 100
Form1.Height = Form1.Height + 100
End Sub
Private Sub Command4_Click()
Form1.Width = Form1.Width - 100
Form1.Height = Form1.Height - 100
End Sub
Private Sub Text1_Change()
End Sub
posted @ 2010-11-10 15:28 Herose 閱讀(102) | 評論 (0) | 編輯 收藏
posted @ 2010-11-10 14:47 Herose 閱讀(104) | 評論 (0) | 編輯 收藏
Private Sub Command1_Click()
Dim a, b, result As Double
a = Text1.Text
b = Text2.Text
result = 0
If b <> 0 Then
result = a / b
Text3 = result
Else
MsgBox "除數不能為0!"
End If
End Sub
posted @ 2010-11-09 20:47 Herose 閱讀(105) | 評論 (0) | 編輯 收藏
posted @ 2010-11-09 18:44 Herose 閱讀(138) | 評論 (0) | 編輯 收藏