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

[¤À¨É] Visual Basic ·s¤â±Ð¾Ç ¤§¹Bºâ¤l

[¤À¨É] Visual Basic ·s¤â±Ð¾Ç ¤§¹Bºâ¤l

¥»©«³Ì«á¥Ñ §b§b ©ó 2010-9-25 02:06 ½s¿è

¦bµ{¦¡»y¨¥¤¤,¹Bºâ¤lºâ¬O¦U¬Û·í±`¥Î¨ìªº,µL½×¦p¦ó,¤£¥i¯à¼g¤@½ú¤lªº Hello World,¦]¦¹¤@©w·|¥Î¨ì¹Bºâ¤l
¥H¤UÂk¯Ç¤F´XºØ¹Bºâ¤l

  • ºâ¼Æ¹Bºâ¤l
  • ³sµ²¹Bºâ¤l
  • ¤ñ¸û¹Bºâ¤l
  • ÅÞ¿è¹Bºâ¤l
  • ¦ì¤¸¹Bºâ¤l


ºâ¼Æ¹Bºâ¤l

  • + ³o­Ó¤£¥Î»¡¤F§a,´N¬O¥[¸¹,¨Ò¦p  3+5 = 8
  • -  ³o­Ó²Å¸¹¤]¬O¬Û·í´¶¹M,´N¬O´î¸¹ ¨Ò¦p 5-3 = 2 ¥t¥~¤@¼h·N¸q´N¬O­t¸¹ ¨Ò¦p-2
  • *  ³o­Ó²Å¸¹´N¬O¼Æ¾Ç¤Wªº­¼¸¹,¨Ò¦p  3*5 = 15
  • /  ³o­Ó²Å¸¹¬O¼Æ¾Ç¤Wªº°£¸¹  ¨Ò¦p   10/8 = 1.25
  • \  ³o­Ó²Å¸¹¬O¾ã¼Æ°£¸¹,¤]´N¬O¤G¼Æ¬Û°£®É¥u¨D¾ã¼Æªº°Ó­È  ¨Ò¦p   20\3 = 6
  • mod ³o­Ó²Å¸¹¬O¨D¾l¼Æ ¨Ò¦p  18 mod 7 ¨äµ²ªG¬°4
  • ^ ³o­Ó²Å¸¹¬O«ü¼Æ¹Bºâ²Å¸¹ ¨Ò¦p 3^4 ´N¬O 3*3*3*3=81




¤ñ¸û¹Bºâ¤l
©Ò¿×¤ñ¸û¹Bºâ¤lÅU¦W«ä·N´N¬O¤G­Ó­È©Îª«¥ó¤¬¬Û¤ñ¸û,©Ò¥H¤@¯ë³£·|¦^¶Ç true ©Î False

  • =  ¤ñ¸û¤G­È¬O§_¬Ûµ¥  ¨Ò¦p MessageBox.Show((3 = 8).ToString()) ¦^¶Ç  False
  • <   ©M¼Æ¾Ç¤Wªº¤p©ó¦P¸q   ¨Ò¦p    MessageBox.Show((3 < 8).ToString()) ¦^¶Ç True
  • >  ©M¼Æ¾Ç¤Wªº¤j©ó¦P¸q    ¨Ò¦p    MessageBox.Show((3 > 8).ToString()) ¦^¶Ç False
  • >= ¤j©ó©Îµ¥©ó     ¨Ò¦p    MessageBox.Show((3 >= 8).ToString()) ¦^¶Ç False
  • <= ¤p©ó©Îµ¥©ó¨Ò¦p    MessageBox.Show((8 <= 8).ToString()) ¦^¶Ç True
  • <>  ¤£µ¥©ó   ¨Ò¦p    MessageBox.Show((3 <> 8).ToString()) ¦^¶Ç True
  • Is  ¤ñ¸û¤Gª«¥ó¬O§_¬Û¦P¬°¦P¤@ª«¥ó¥ó,¨Ò¦p
    1. Public Class Form1

    2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.         Dim A As New Button
    4.         Dim b As New Button
    5.         MessageBox.Show((A Is b).ToString)
    6.     End Sub
    7. End Class
    ½Æ»s¥N½X
    ³o­Óµª®×¬OFalse , ªí¥Ü a ©Mb ¬O¤G­Ó­Ó¦Û¿W¥ßªº«ö¶s
    ¦ý¦pªG¬O
    1. Public Class Form1
    2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.         Dim A As New Button
    4.         Dim b As Button = A
    5.         MessageBox.Show((A Is b).ToString)
    6.     End Sub
    7. End Class
    ½Æ»s¥N½X
    ªí¥Üa©Mb¬O¬Û¦Pªºªºª«¥ó,©Ò¥H¦^¶Çtrue,­Y¥H¦ì§}ªºÃö«Y¨Ó¬Ý,²Ä¤@­Óµ{¦¡a©Mbªº¦ì§}¤£¦P,¦ý²Ä¤G­Óµ{¦¡¤¤a©Mb«ü¦V¦P¤@­Ó¦ì§}

  • TypeOf.......Is
    ¤@¯ë¦Ó¨¥³o­Ó¥Î¨Ó¬d¬Ý¬O§_¬Y­Óª«¥ó²Å¦X¬Y¤@«¬ºA,¦pªG¬Oªº¸Ü´N¥i¥H¶i¦æÂà´«,¦]¬°¦bVb.net¼g§@®É§Æ±æ¹F¨ì±j«¬§Oªº­n¨D,³o¼Ë¥i¥H¼W¥[µ{¦¡½Xªº¦w¥þ©Ê
    ¨Ò¦p
    1. Public Class Form1
    2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    3.         If TypeOf sender Is Button Then

    4.             MessageBox.Show(DirectCast(sender, Button).Text)

    5.         End If
    6.     End Sub
    7. End Class
    ½Æ»s¥N½X
  • Like Like ¹Bºâ¤l¤@¯ë¥Î¦b¦r¦êªº«¬¦¡¤ñ¸û¨Ò¦p
       MessageBox.Show("F" Like "[A-Z]") ¦^¶ÇTrue ¦]¬°F¬°A-Z¨ä¤¤¤§¤@¦r¤¸
       ·íµM§Ú­Ì¥i¥H¬¡¥Î±qdos®É¥N´N¯d¤U¨Óªº¸U¥Î¦r¤¸¦p¥H¤U¤]¬O¦^¶Çtrue
         MessageBox.Show("Casting" Like "Ca?t*")
       *¥Nªíªº¬O¤@¦ê¦r,¦Ó?¥Nªíªº¬O¤@­Ó¦r¤¸


«ü©w¹Bºâ¤l ¤ñ¸û¤£¦P©ó¼Æ¾Ç¤Wªºµ¥¸¹ ³o¸Ìªº·N«ä¬O «ü©w¬Y¤@­Ó­Èµ¹¬Y¤@ÅܼÆ
¦p   X= 1, ¥Nªíªº·N«ä¬O ±N1«ü©wµ¹X,¦Ó¤£¬OX µ¥©ó1 ¦]¦¹·|¦³   X = X+1 ³o¼Ëªº³¯­z ±N X ­ì¥»¥[1«á¦A«ü©wµ¹X

³sµ²¹Bºâ¤l VB¤¤¦r¦êªº³sµ²¥i¥H¦³¤G­Ó¹Bºâ¤l¨Ï¥Î,¤@­Ó¬O§Q¥Î+ ,¥t¤@­Ó¬O &

        MessageBox.Show("abc" + "def")
        MessageBox.Show("abc"  &  "def")
¬°µ¥¿é¥X

ÅÞ¿è¹Bºâ¤l
Not   : ¨Ò¦p         
Dim A As Boolean = False
        MessageBox.Show(Not A).ToString()
«h·|Åã¥Ü¥X true , ¤]´N¬O©M­ì¥ý­È¬Û¤Ïªº·N«ä

Xor
¥u¦³·í A  ©M B³£¬Ofalse ©Î ¬O ³£¬O true®É ¤~·|¬Ofalse
¨ä¾l³£¬Otrue

And
·í A ©M B³£¬O true ®É ¤~·|¬O true ¨ä¾l³£¬O False

Or
·íA©MB ¥ô¤@­Ó¬Otrue®É´N¬Otrue

AndAlso
©MAndªº®ÄªG¬O¤@¼Ë,¦ý®Ä²v¤£¦P,­ì¦]¦b©óandalso¥u­n§P©w«e­±¤@­Ó¬Ofalse´N¤£·|¥h§PÂ_¤U¤@­Óª½±µ´N¦^À³false,µM¦Ó and ¬O·| A ©MB ³£§PÂ_§¹¦¨¤F,¤~·|¥h¦^À³

        ÀR«ä¦Û¦b : ÁÀ¨¥¹³¤@¦·²±¶}ªºÂAªá¡A¥~ªí¬üÄR¡A¥Í©Rµu¼È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD