1. 程式人生 > >vb入門+vs2010(20180208)

vb入門+vs2010(20180208)

string 單擊 sub ger 代碼 geb rgs else button

1.創建窗體

在彈出菜單中選擇【添加】---->【Windows窗體】,然後輸入窗體名(我都用的默認名),單擊完成

2.添加控件

在窗體上添加一個Button按鈕

3.添加代碼

Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

‘-----------------------if多重判斷用例--------------------------

‘ If CInt(TextBox1.Text) > 5 Then

‘ MessageBox.Show("你輸入的數大於5")

‘ ElseIf CInt(TextBox1.Text) = 5 Then

‘ MessageBox.Show("你輸入的數等於5")

‘ Else

‘ MessageBox.Show("你輸入的數小於5")

‘ End If

‘-----------------------select case用例-------------------------

‘Dim a As Integer = CInt(TextBox1.Text)

‘Select Case a

‘ Case 1, 3, 5, 7, 9

‘ MessageBox.Show("你輸入的是小於10的單數")

‘ Case 8 To 12

‘ MessageBox.Show("你輸入的是8到12之間的數")

‘ Case 13 To 25

‘ MessageBox.Show("你輸入的是13到25之間的數")

‘ Case 31 To 35, Is > 50

‘ MessageBox.Show("你輸入的是31到35之間的數或大於50的數")

‘End Select

‘----------------------for.....next語句用例---------------------

‘Dim i, s As Integer

‘For i = 0 To 100

‘ s = s + i

‘Next

‘MessageBox.Show("累計和為" & (s))

‘----------------------for.....each語句用例---------------------

‘ Dim i As Integer

‘ Dim a() As String = {"第二章", "語法學習", "學習"}

‘ For Each a(i) In a

‘ MessageBox.Show(a(i))

‘ Next

End Sub

End Class

今天就寫這麽些吧!

明天繼續!

vb入門+vs2010(20180208)