The funeral of Azeroth

Herose

 

2010年11月12日

Vb11.12 VB 中基本语句

1.If
Private Sub Command1_Click()
Dim a As String      "声明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
= 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
= Rnd
= 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
= Text1.Text
Select Case a
Case "红色"
Label1.BackColor 
= RGB(25500)
Case "绿色"
Label1.BackColor 
= RGB(02550)
Case "蓝色"
Label1.BackColor 
= RGB(00255)
Case Else
Label1.BackColor 
= RGB(2552550)
End Select

End Sub
5.do .....loop
Private Sub Command1_Click()
Dim a, b, s, i As Integer  "整型"
= Val(text1.Text)
= Val(text2.Text)
= 0
= a
Do While i <= b    
= s + 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
= Val(Text1.Text)
= Val(Text2.Text)
= 0
= a
While i <= b
= s + 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
= Val(Text1.Text)
= Val(Text2.Text)
= 0
= a
For i = a To b Step 2
= s + i
Next
MsgBox "计算结果为:" & s

End Sub



posted @ 2010-11-12 16:30 Herose 阅读(106) | 评论 (0)编辑 收藏

2010年11月11日

Vb11.11

1.数据类型转换函数
 
Private Sub command1_Click()
Dim a As String
a
=Val(text1.text)
Msgbox "转换后的结果是:"& CDbl(a) 双晶度数据
Msgbox "转换后的结果是:"& CLng(a) 长整型的
Msgbox "转换后的结果是:"& CSng(a) 单晶度型的
Msgbox "转换后的结果是:"& VCar(a) 转换成变体的(免声明)
Msgbox "转换后的结果是:"& CStr(a) 字符串的
Msgbox "转换后的结果是:"& Cdate(a) 日期的
Msgbox "转换后的结果是:"& CDbl(a)
2.日期和时间函数
Private Sub command1_Click()
MsgBox "当前日期时间为:" & Now()
   Msgbox "当前日期为:" &date()
End sub
Private Sub command1_Click()
Dim a As String
a
=CDate(Text1.text)
Msgbox "当前日期年份为:" &Year(a)
Msgbox "当前日期月份为:" &Month(a)
Msgbox "当前日期日子为:" &Day(a)
Msgbox "当前日期星期为:" &Weekday(a)
Msgbox "当前为:" &Hour(a)
MsgBox "当前为:" &Minute(a)
Msgbox "当前为:" &Second(a)

End Sub
3.
Private Sub form_Click()
Print 
"姓名" ;tab(10) ;"籍贯"   指定的第十行
Print 
"姓名" ;Spc(20) ; "籍贯" 产生20空格
Print 
"姓名" ; Space(30);"籍贯" "可用在字符串中"
End Sub
Private Sub form_Click()
Print format(
123456.365,"######.##")
End sub
Private Sub Form_Click()
Dim a As String
= InputBox("请输入内容""输入框""Herose")
Print a

End Sub
Private Sub Form_Click()
MsgBox "你好,你吃饭了吗?"

End Sub

posted @ 2010-11-11 17:46 Herose 阅读(78) | 评论 (0)编辑 收藏

Vb11.11 "函数"

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入

posted @ 2010-11-11 15:03 Herose 阅读(96) | 评论 (0)编辑 收藏

2010年11月10日

vb11.10 声明

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 阅读(100) | 评论 (0)编辑 收藏

vb 11.10 else

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


posted @ 2010-11-10 16:59 Herose 阅读(95) | 评论 (0)编辑 收藏

vb 11.10 "ROLL "元素

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 阅读(85) | 评论 (0)编辑 收藏

vb.11.10 帅哥成长器




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 阅读(95) | 评论 (0)编辑 收藏

vb11.10

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

posted @ 2010-11-10 14:47 Herose 阅读(97) | 评论 (0)编辑 收藏

2010年11月9日

vb.11.9

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 阅读(98) | 评论 (0)编辑 收藏

Vb11.9

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

posted @ 2010-11-09 18:44 Herose 阅读(130) | 评论 (0)编辑 收藏

仅列出标题  

导航

统计

常用链接

留言簿(3)

随笔档案

文章档案

相册

http://www.enet.com.cn/eschool/video/vb/

搜索

最新评论

阅读排行榜

评论排行榜