2010年11月9日
1.If
Private Sub Command1_Click()
Dim a As String "声明a是字符串形式的变量"
a = Text1.Text
If a = "你好" Then
MsgBox "你输入的是你好"
ElseIf a <> "你好" Then 或 Else
MsgBox "你输入的并非是你好"
End If
End Sub
2.if
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
If a = "邱吉尔" Then
MsgBox "恭喜你,回答正确"
ElseIf a = "罗斯福" Then
MsgBox "恭喜你,回答正确"
ElseIf a = "斯大林" Then
MsgBox "恭喜你,回答正确"
Else
MsgBox "对不起,你真笨"
End If
End Sub
3.
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
4.Select case
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
Select Case a
Case "红色"
Label1.BackColor = RGB(255, 0, 0)
Case "绿色"
Label1.BackColor = RGB(0, 255, 0)
Case "蓝色"
Label1.BackColor = RGB(0, 0, 255)
Case Else
Label1.BackColor = RGB(255, 255, 0)
End Select
End Sub
5.do .....loop
Private Sub Command1_Click()
Dim a, b, s, i As Integer "整型"
a = Val(text1.Text)
b = Val(text2.Text)
s = 0
i = a
Do While i <= b
s = s + i
i = i + 1
Loop
MsgBox "计算结果为" & s
Do loop 的另一种形式
Do
s=s+i
i=i+1
Loop while i<=b
End Sub
"计算两个整数之间所有整数之和(包括这两个整数)"
6. do while 当条件满足时候执行
do until 当条件不满足时候执行
Do
s=s+i
i=i+1
Loop until i>b
7.While...(条件满足时) Wend(执行)
Private Sub Command1_Click()
Dim a, b, s, i As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
s = 0
i = a
While i <= b
s = s + i
i = i + 1
Wend
MsgBox "计算结果为:" & s
End Sub
8.For a to b Step 2 计算a到b之间间隔为2的所有数之和
Private Sub Command1_Click()
Dim a, b, s, i As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
s = 0
i = a
For i = a To b Step 2
s = s + i
Next
MsgBox "计算结果为:" & s
End Sub
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
2.不知道是高中还是初中的东西,现在都记不起来了,百度了一下,还是一头雾水,
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
3. Els val
Trim 删除空格
Ltrim 删除左空格
Rtrim 删除右空格
Left(s,6) 选取左六
Mid (s,2,6) 取指定位置的字符串
Right(s,6) 从右选6字符串
4.Dim a as
Variant
len(a) 长度
Space (a) 空格为
UCase(a) 大写
LCase(a) 小写 a=Val(Text1.text) 数字
Str(a) 数字转字符
5.Dim a,b As
String
Instr(a,b) 若字符串B是A的子串,结果为1,反之则为0
6.
Val 将字符串转为数字
Str 将数字转为字符串
Asc(a) 字符串首字的Ascii 码
Chr(a)得到以数字为Ascii码的字符
7.随机函数
Rnd(a) a不变则随机值不变 CInt 将数字小数第一们4舍5入 CCur (a) 将小数后第五位4舍5入
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
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
mouse 随text1变化而变化
Form1.MousePointer = Form1.Text1.Text
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
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
Form1.Width = Form1.Width + 100
Form1.Height = Form1.Height +100
每次Click 窗体,工程的高度和宽度就会增加100
Private Sub Form
Click()
Form1.
Print "这是一种喜爱
"
End Sub
Private Sub Form_Load()
Form1.
FontBold=True "粗"
Form1.
FontItalic=True "斜"
Form1.
FontUnderline=true "下划线"
End sub
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
Java for me is very far away;
Because I just graduated from high school,don't read any university;
But I really love it,
Although I lost myself a few years
But now ,I stand up again;
Perhaps everyone has a dream,
And the dream is our forward strength,
Beginning from today
I will redouble our efforts to realize the dream
write by pony 2010 November 9th