ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] visual basic.net ·s¤â±Ð¾Ç¤§°ò¥»¬yµ{

[¤À¨É] visual basic.net ·s¤â±Ð¾Ç¤§°ò¥»¬yµ{

¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-16 23:39 ½s¿è

³o¸Ì­n»¡ªº¬O©Ò¦³¶}µo¦¡µ{¦¡»y¨¥À³¸Ó³£·|¦³ªº³¡¤À,¤£½×§A¬O¾Ç¨º¤@ºØµ{¦¡»y¨¥,À³¸Ó³£¤£·|¦³¤Ó¤jªº¤£¦P

  • ¨Mµ¦


  • if ª¬ªp¤@  then .....   end if
    ³o­Ó³¯­z¥yªº·N«ä¬O,¦pªG²Å¦Xª¬ªp¤@,¨º´N°µ¬Y¤@¥ó¨Æ
    ³o­Ó«Ü®e©öÁ|¨Ò,§Ú¦b¤p¾Çªº®É­Ô,¦Ñ®v®É±`»¡,¦Ò¸Õ¤£¤Î®æªÌ,¤Ö¤@¤À¥´¤@¤U, ©Ò¥H´NÅܦ¨
    1. Public Class Form1
    2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.         Dim ¦Ò¸Õ¤À¼Æ As Integer
    4.         Const ¤Î®æ¤À¼Æ As Integer = 60
    5.         ¦Ò¸Õ¤À¼Æ = 53
    6.         Dim ³Q¥´¦¸¼Æ As Integer = ¤Î®æ¤À¼Æ - ¦Ò¸Õ¤À¼Æ
    7.         If ³Q¥´¦¸¼Æ > 0 Then MessageBox.Show("§A­n³Q¥´" & ³Q¥´¦¸¼Æ & "¤U")
    8.     End Sub
    9. End Class
    ½Æ»s¥N½X
    ¤W­±³o­Ó·N«ä¬O»¡,¦pªG³Q¥´¦¸¼Æ¤j©ó0¤~·|Ä~Äò°õ¦æ¥H¤Uªº°Ê§@,¦Ó·Ó²z»¡
    If ³Q¥´¦¸¼Æ > 0 Then MessageBox.Show("§A­n³Q¥´" & ³Q¥´¦¸¼Æ & "¤U") À³¸ÓÁÙ­n¥[¤@¥y end if
    ´N¹³¬O³o¼Ë
    If ³Q¥´¦¸¼Æ > 0 Then
         MessageBox.Show("§A­n³Q¥´" & ³Q¥´¦¸¼Æ & "¤U")
    end if
    ¦ý¦]¬°¥y¤l«Üµu  ¥u¦³¤@¦C visual basic  ¤¹³\ §Ú­Ì¤£¼gend if ¦pªG¶W¹L¤@¦æ,¨º§A´N­n¼g¤F
    ·íµM,³o¼Ëªº³¯­z¦³®É­ÔÁÙ¤£°÷,§Ú­Ì·Q­n¤Î®æªº¤H¤]¦³¬ÛÃöªº¦^À³,¦]¦¹¦³³o­Ó¹ïÀ³ªº»yªk
  •   if ª¬ªp¤@  then
             ' §A·Q­n°µªº¨Æ
        else
             ' §A·Q­n°µªº¨Æ
        end if

    ¥H¤U¬°¨Ò¤l
    1. Public Class Form1
    2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    3.         Dim ¦Ò¸Õ¤À¼Æ As Integer

    4.         Const ¤Î®æ¤À¼Æ As Integer = 60

    5.         ¦Ò¸Õ¤À¼Æ = 60
    6.         Dim ³Q¥´¦¸¼Æ As Integer = ¤Î®æ¤À¼Æ - ¦Ò¸Õ¤À¼Æ

    7.         If ³Q¥´¦¸¼Æ > 0 Then
    8.         Else
    9.             MessageBox.Show("®¥³ß§A°k¹L¤@§T")
    10.         End If

    11.     End Sub
    12. 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·Q­n°µªº¨Æ
           elseif ª¬ªp¤G then
                  '§A·Q­n°µªº¨Æ
           elseif ª¬ªp¤T then
                  '§A·Q­n°µªº¨Æ
    .......
    elseif ª¬ªp¤£ª¾¤Z´X then
                  '§A·Q­n°µªº¨Æ
        else
             ' §A·Q­n°µªº¨Æ
        end if

      ¥H¤U¬O½d¨Ò
    1. Public Class Form1
    2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    3.         Dim ¦Ò¸Õ¤À¼Æ As Integer

    4.         ¦Ò¸Õ¤À¼Æ = 89
    5.         If ¦Ò¸Õ¤À¼Æ = 100 Then
    6.             MessageBox.Show("§¹¬ü")
    7.         ElseIf ¦Ò¸Õ¤À¼Æ >= 90 Then
    8.             MessageBox.Show("Àu¨q")
    9.         ElseIf ¦Ò¸Õ¤À¼Æ >= 80 Then
    10.             MessageBox.Show("¨ã¦³¬Û·í¹ê¤O")
    11.         ElseIf ¦Ò¸Õ¤À¼Æ >= 70 Then
    12.             MessageBox.Show("¤£¿ù,¥[ªo")
    13.         ElseIf ¦Ò¸Õ¤À¼Æ >= 60 Then
    14.             MessageBox.Show("¦nÀI")
    15.         Else
    16.             MessageBox.Show("¤í´~")
    17.         End If
    18.       
    19.     End Sub
    20. 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¨Ò
    1. Public Class Form1
    2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    3.         Dim ª¬ªp¦^À³ As DialogResult

    4.         ª¬ªp¦^À³ = MessageBox.Show("ª¬ªp¦^À³", "´ú¸Õ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)

    5.         Select Case ª¬ªp¦^À³
    6.         Case Windows.Forms.DialogResult.No
    7.                 MessageBox.Show("NO")
    8.             Case Windows.Forms.DialogResult.Yes
    9.                 MessageBox.Show("Yes")
    10.             Case Else
    11.                 MessageBox.Show("¤í´~")

    12.         End Select

    13.     End Sub
    14. End Class
    ½Æ»s¥N½X

  • °j°é

    °j°é¤]¬Oµ{¦¡»y¨¥¬ÛÀÉ­«­nªº¤@Àô
    ¥H¤U¤¶²Ð´XºØ


    • For  i = ¶}©l to µ²§ô step »¼¼W¶q
      '§A·Q­n°µªº¨Æ
      Next i
      ¥H¤U¬°½d¨Ò
      1. Public Class Form1
      2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


      3.         Dim ­p¼Æ As Integer
      4.         For i As Integer = 0 To 10 Step 1
      5.             ­p¼Æ = ­p¼Æ + 1
      6.         Next i

      7.         MessageBox.Show(­p¼Æ)

      8.     End Sub
      9. End Class
      ½Æ»s¥N½X
      ±q0¨ì10¤@¦@°µ¤F11¦¸
      ¹ê»Ú¤W, step 1¥i¥H¤£¼g ¦]¬°¤º©w´N¬O step 1
      ©Ò¥H§Ú­Ì¥i¥H§ï¦¨
      1. Public Class Form1
      2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


      3.         Dim ­p¼Æ As Integer
      4.         For i As Integer = 0 To 10 Step 2
      5.             ­p¼Æ = ­p¼Æ + 1
      6.         Next i

      7.         MessageBox.Show(­p¼Æ)

      8.     End Sub
      9. 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
      '°µ§A­n°µªº¨Æ
      Loop
      1. Public Class Form1
      2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      3.         Dim i As Integer = 0
      4.         Dim Á`©M As Integer = 0
      5.         Do While Á`©M < 1000
      6.             i = i + 1
      7.             Á`©M = Á`©M + i
      8.         Loop
      9.         MessageBox.Show("Á`¦@°µ¤F" & i.ToString & "¦¸" & "Á`©M=" & Á`©M.ToString)
      10.     End Sub
      11. End Class
      ½Æ»s¥N½X
      ³o­Óµ{¦¡½X§i¶D§Ú­Ì,·íÁ`©M¤j©ó1000®É·|Â÷¶}°j°é,©Ò±oªºµ²ªG¬O¤j©ó1000ªº³Ì¤p¼Æ
    • Do
                 ' §A­n°µªº¨Æ
           Loop Until ª¬ªp敍­z

      ¤W­±ªºµ{¦¡½X§ï¼g´NÅܦ¨¥H¤U,§PÂ_¦¡¼g¦b«á­±ªº·N¸q¦b©ó¤@©w·|¥ý°µ¤@¦¸, ¦Ódo While ©M do Until ­è¦n¬O¬Û¤Ï
      1. Public Class Form1

      2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      3.         Dim i As Integer = 0
      4.         Dim Á`©M As Integer = 0
      5.         Do
      6.             i = i + 1
      7.             Á`©M = Á`©M + i
      8.         Loop Until Á`©M >= 1000
      9.         MessageBox.Show("Á`¦@°µ¤F" & i.ToString & "¦¸" & "Á`©M=" & Á`©M.ToString)

      10.     End Sub
      11. End Class
      ½Æ»s¥N½X
    • For each ³æ¤¸ in ¶°¦X
      '§A­n°µªº¨Æ
          next ³æ¤¸


      ³oºØ»yªk¤@¯ë·|¥Î¦b°}¦C,¶°¦X³oºØ®e¾¹ÃþªºªF¦èªº¦s¨ú
      1. Public Class Form1
      2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      3.         Dim ¤@¬P´Á() As String = {"¬P´Á¤é", "¬P´Á¤@", "¬P´Á¤G", "¬P´Á¤T", "¬P´Á¥|", " ¬P´Á¤­", "¬P´Á¤»"}

      4.         For Each day As String In ¤@¬P´Á
      5.             MessageBox.Show(day)
      6.         Next
      7.     End Sub
      8. End Class
      ½Æ»s¥N½X
      ©ÎªÌ¤]¥i¥H§Q¥ÎIEnumerator ¤¶­±
      1. Public Class Form1
      2.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      3.         Dim ¤@¬P´Á() As String = {"¬P´Á¤é", "¬P´Á¤@", "¬P´Á¤G", "¬P´Á¤T", "¬P´Á¥|", " ¬P´Á¤­", "¬P´Á¤»"}
      4.         Dim f As IEnumerator = ¤@¬P´Á.GetEnumerator
      5.         While f.MoveNext
      6.             MessageBox.Show(DirectCast(f.Current, String))
      7.         End While
      8.     End Sub
      9. End Class
      ½Æ»s¥N½X

  •         ÀR«ä¦Û¦b : ¦¨¥\¬OÀuÂIªºµo´§¡A¥¢±Ñ¬O¯ÊÂIªº²Ö¿n¡C
    ªð¦^¦Cªí ¤W¤@¥DÃD