- ©«¤l
- 57
- ¥DÃD
- 7
- ºëµØ
- 3
- ¿n¤À
- 60
- ÂI¦W
- 0
- §@·~¨t²Î
- WINDOWSXP
- ³nÅ骩¥»
- 2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-3
- ³Ì«áµn¿ý
- 2011-4-9
|
[¤À¨É] visual basic.net ·s¤â±Ð¾Ç¤§°ò¥»¬yµ{
¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-16 23:39 ½s¿è
³o¸Ìn»¡ªº¬O©Ò¦³¶}µo¦¡µ{¦¡»y¨¥À³¸Ó³£·|¦³ªº³¡¤À,¤£½×§A¬O¾Ç¨º¤@ºØµ{¦¡»y¨¥,À³¸Ó³£¤£·|¦³¤Ó¤jªº¤£¦P
- if ª¬ªp¤@ then ..... end if
³oÓ³¯z¥yªº·N«ä¬O,¦pªG²Å¦Xª¬ªp¤@,¨º´N°µ¬Y¤@¥ó¨Æ
³oÓ«Ü®e©öÁ|¨Ò,§Ú¦b¤p¾Çªº®ÉÔ,¦Ñ®v®É±`»¡,¦Ò¸Õ¤£¤Î®æªÌ,¤Ö¤@¤À¥´¤@¤U, ©Ò¥H´NÅܦ¨- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim ¦Ò¸Õ¤À¼Æ As Integer
- Const ¤Î®æ¤À¼Æ As Integer = 60
- ¦Ò¸Õ¤À¼Æ = 53
- Dim ³Q¥´¦¸¼Æ As Integer = ¤Î®æ¤À¼Æ - ¦Ò¸Õ¤À¼Æ
- If ³Q¥´¦¸¼Æ > 0 Then MessageBox.Show("§An³Q¥´" & ³Q¥´¦¸¼Æ & "¤U")
- End Sub
- End Class
½Æ»s¥N½X ¤W±³oÓ·N«ä¬O»¡,¦pªG³Q¥´¦¸¼Æ¤j©ó0¤~·|Ä~Äò°õ¦æ¥H¤Uªº°Ê§@,¦Ó·Ó²z»¡
If ³Q¥´¦¸¼Æ > 0 Then MessageBox.Show("§An³Q¥´" & ³Q¥´¦¸¼Æ & "¤U") À³¸ÓÁÙn¥[¤@¥y end if
´N¹³¬O³o¼Ë
If ³Q¥´¦¸¼Æ > 0 Then
MessageBox.Show("§An³Q¥´" & ³Q¥´¦¸¼Æ & "¤U")
end if
¦ý¦]¬°¥y¤l«Üµu ¥u¦³¤@¦C visual basic ¤¹³\ §Ṳ́£¼gend if ¦pªG¶W¹L¤@¦æ,¨º§A´Nn¼g¤F
·íµM,³o¼Ëªº³¯z¦³®ÉÔÁÙ¤£°÷,§ÚÌ·Qn¤Î®æªº¤H¤]¦³¬ÛÃöªº¦^À³,¦]¦¹¦³³oÓ¹ïÀ³ªº»yªk
- if ª¬ªp¤@ then
' §A·Qn°µªº¨Æ
else
' §A·Qn°µªº¨Æ
end if
¥H¤U¬°¨Ò¤l- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim ¦Ò¸Õ¤À¼Æ As Integer
- Const ¤Î®æ¤À¼Æ As Integer = 60
- ¦Ò¸Õ¤À¼Æ = 60
- Dim ³Q¥´¦¸¼Æ As Integer = ¤Î®æ¤À¼Æ - ¦Ò¸Õ¤À¼Æ
- If ³Q¥´¦¸¼Æ > 0 Then
- Else
- MessageBox.Show("®¥³ß§A°k¹L¤@§T")
- End If
- End Sub
- End Class
½Æ»s¥N½X ³oÀ³¸Ó¦A®e©ö¤£¹L¤F,¤£¹L¬O¼Æ¾Çªº¤T¤@«ß,¤£¬O¤j©ó,´N¬O¤p©ó,¦A¤£´N¬Oµ¥©ó,¨S¦³¨ä¥¦ª¬ªp¤F
§Ú̳]©w¤F ¤j©ó 0 ,¨º¨ä¥¦ªº³¡¤À´N¬O ¤p©ó ©Mµ¥©ó 0 ªº³¡¤À
¦ý§ÚÌ¥u¦³§C©ó60¤Àªº³¡¤À,©M°ª©ó©Îµ¥©ó60¤À,¦ý¨ä¥¦ªº¤À¼Æ°Ï¶¡§Ṳ́]·Q°µ¤@Ó¦^À³,À³¸Ó«ç»ò°µ,visual basic ¤]´£¨Ñ¤F
¹ïÀ³ªº»yªk
- if ª¬ªp¤@ then
' §A·Qn°µªº¨Æ
elseif ª¬ªp¤G then
'§A·Qn°µªº¨Æ
elseif ª¬ªp¤T then
'§A·Qn°µªº¨Æ
.......
elseif ª¬ªp¤£ª¾¤Z´X then
'§A·Qn°µªº¨Æ
else
' §A·Qn°µªº¨Æ
end if
¥H¤U¬O½d¨Ò- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim ¦Ò¸Õ¤À¼Æ As Integer
- ¦Ò¸Õ¤À¼Æ = 89
- If ¦Ò¸Õ¤À¼Æ = 100 Then
- MessageBox.Show("§¹¬ü")
- ElseIf ¦Ò¸Õ¤À¼Æ >= 90 Then
- MessageBox.Show("Àu¨q")
- ElseIf ¦Ò¸Õ¤À¼Æ >= 80 Then
- MessageBox.Show("¨ã¦³¬Û·í¹ê¤O")
- ElseIf ¦Ò¸Õ¤À¼Æ >= 70 Then
- MessageBox.Show("¤£¿ù,¥[ªo")
- ElseIf ¦Ò¸Õ¤À¼Æ >= 60 Then
- MessageBox.Show("¦nÀI")
- Else
- MessageBox.Show("¤í´~")
- End If
-
- End Sub
- End Class
½Æ»s¥N½X ¥H¤W if else ªº»yªk ¤ñ¸û¤£¨ã¥iŪ©Ê,¦³¤@ºØ¥s select case ªº»yªk,Åý§Ú̧ó¯à®e©ö¤F¸Ñµ{¦¡½X¦b°µ¤°»ò
-
Select Case (¬Y¤@ÅܼÆ,¦CÁ|)
Case ª¬ªp¤@
'§A·Q°µªº¨Æ
Case ª¬ªp¤G
'§A·Q°µªº¨Æ
Case ¤£ª¾¤Z´X
'§A·Q°µªº¨Æ
......
Case else
'§A·Q°µªº¨Æ
End Select
¥H¤U¬°½d¨Ò- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim ª¬ªp¦^À³ As DialogResult
- ª¬ªp¦^À³ = MessageBox.Show("ª¬ªp¦^À³", "´ú¸Õ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
- Select Case ª¬ªp¦^À³
- Case Windows.Forms.DialogResult.No
- MessageBox.Show("NO")
- Case Windows.Forms.DialogResult.Yes
- MessageBox.Show("Yes")
- Case Else
- MessageBox.Show("¤í´~")
- End Select
- End Sub
- End Class
½Æ»s¥N½X
°j°é
°j°é¤]¬Oµ{¦¡»y¨¥¬ÛÀÉ«nªº¤@Àô
¥H¤U¤¶²Ð´XºØ
For i = ¶}©l to µ²§ô step »¼¼W¶q
'§A·Qn°µªº¨Æ
Next i
¥H¤U¬°½d¨Ò
- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim p¼Æ As Integer
- For i As Integer = 0 To 10 Step 1
- p¼Æ = p¼Æ + 1
- Next i
- MessageBox.Show(p¼Æ)
- End Sub
- End Class
½Æ»s¥N½X ±q0¨ì10¤@¦@°µ¤F11¦¸
¹ê»Ú¤W, step 1¥i¥H¤£¼g ¦]¬°¤º©w´N¬O step 1
©Ò¥H§ÚÌ¥i¥H§ï¦¨- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim p¼Æ As Integer
- For i As Integer = 0 To 10 Step 2
- p¼Æ = p¼Æ + 1
- Next i
- MessageBox.Show(p¼Æ)
- End Sub
- End Class
½Æ»s¥N½X °µ¤F6¦¸
¦ý³oºØ°j°é¥u¦³·í«e«áȤ@¶}©l´N¨M©wªº®É·|¤~¦³®Ä
¦pªG¤@¶}©lµLªk½T©w¨ºn¦p¦ó©O
§ÚÌ´N¦³¥t¥~¤@ºØ°j°é²£¥Í
- Do While ª¬ªp敍z
'°µ§An°µªº¨Æ
Loop- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim i As Integer = 0
- Dim Á`©M As Integer = 0
- Do While Á`©M < 1000
- i = i + 1
- Á`©M = Á`©M + i
- Loop
- MessageBox.Show("Á`¦@°µ¤F" & i.ToString & "¦¸" & "Á`©M=" & Á`©M.ToString)
- End Sub
- End Class
½Æ»s¥N½X ³oÓµ{¦¡½X§i¶D§ÚÌ,·íÁ`©M¤j©ó1000®É·|Â÷¶}°j°é,©Ò±oªºµ²ªG¬O¤j©ó1000ªº³Ì¤p¼Æ
- Do
' §An°µªº¨Æ
Loop Until ª¬ªp敍z
¤W±ªºµ{¦¡½X§ï¼g´NÅܦ¨¥H¤U,§PÂ_¦¡¼g¦b«á±ªº·N¸q¦b©ó¤@©w·|¥ý°µ¤@¦¸, ¦Ódo While ©M do Until è¦n¬O¬Û¤Ï- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim i As Integer = 0
- Dim Á`©M As Integer = 0
- Do
- i = i + 1
- Á`©M = Á`©M + i
- Loop Until Á`©M >= 1000
- MessageBox.Show("Á`¦@°µ¤F" & i.ToString & "¦¸" & "Á`©M=" & Á`©M.ToString)
- End Sub
- End Class
½Æ»s¥N½X - For each ³æ¤¸ in ¶°¦X
'§An°µªº¨Æ
next ³æ¤¸
³oºØ»yªk¤@¯ë·|¥Î¦b°}¦C,¶°¦X³oºØ®e¾¹ÃþªºªF¦èªº¦s¨ú- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim ¤@¬P´Á() As String = {"¬P´Á¤é", "¬P´Á¤@", "¬P´Á¤G", "¬P´Á¤T", "¬P´Á¥|", " ¬P´Á¤", "¬P´Á¤»"}
- For Each day As String In ¤@¬P´Á
- MessageBox.Show(day)
- Next
- End Sub
- End Class
½Æ»s¥N½X ©ÎªÌ¤]¥i¥H§Q¥ÎIEnumerator ¤¶±- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim ¤@¬P´Á() As String = {"¬P´Á¤é", "¬P´Á¤@", "¬P´Á¤G", "¬P´Á¤T", "¬P´Á¥|", " ¬P´Á¤", "¬P´Á¤»"}
- Dim f As IEnumerator = ¤@¬P´Á.GetEnumerator
- While f.MoveNext
- MessageBox.Show(DirectCast(f.Current, String))
- End While
- End Sub
- End Class
½Æ»s¥N½X
|
|