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 閱讀(113) | 評論 (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 閱讀(85) | 評論 (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 閱讀(103) | 評論 (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 閱讀(109) | 評論 (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 閱讀(101) | 評論 (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 閱讀(92) | 評論 (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 閱讀(102) | 評論 (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 閱讀(104) | 評論 (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 閱讀(105) | 評論 (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 閱讀(138) | 評論 (0)編輯 收藏

          僅列出標題  

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆檔案

          文章檔案

          相冊

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

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 泸州市| 舟曲县| 甘肃省| 塔城市| 偏关县| 沛县| 济南市| 濮阳县| 繁峙县| 江门市| 昌吉市| 竹山县| 东安县| 钦州市| 麻江县| 独山县| 华蓥市| 永平县| 延长县| 钦州市| 湖口县| 呼玛县| 木里| 尼玛县| 威信县| 丰城市| 泰顺县| 波密县| 永兴县| 阜新| 南靖县| 阿克苏市| 上杭县| 凉山| 苏尼特左旗| 印江| 扬州市| 龙川县| 平凉市| 和田市| 海兴县|