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

[¤À¨É] visual basic.net ·s¤â±Ð¾Ç

[¤À¨É] visual basic.net ·s¤â±Ð¾Ç

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

¦b³o¸Ìªº«eÃD¬O,§Ú¬O¥Îvb2008 Express ª©¥»,¦³¥ô¦ó¾Þ§@¤¶­±¤£¦Pªº,©Î§ä¤£¨ì¹ïÀ³ªº,­ì½Ì§ÚµLªkµªÂÐ
­Y±z¨S¦³,¥i¨ì©xºô¤U¸ü¤U¸üºô§}

  • ·íµM,¤@¶}©l¬O¥þ¥@¬É¼g±o³Ì¦h¦¸ªºµ{¦¡½X,HelloWorld
  • §Ú­Ì¥´¶}visual basic 2008 «á,¶}啓¤@­ÓWindowsForm±M®×
  • §A·|¬Ý¨ì¤@­ÓWindowsForm , ³o¬OMicrosoft¦b­Ó¤H¾Þ§@¤¶­±¤W¤w¸g横¦æ¤Q¼Æ¦~ªºªF¦è,§ÚµL¥²­n¦b¦¹¦h¥[´y­z
  • §A¥i¥H¦b¥ªÃ䪺¤u¨ã½c¤¤©Ô¤@­Ó«ö¶s¨ìForm¤W,µM«áÂùÀ»¸Ó«ö¶s,µM«á§A·|¬Ý¨ì¥H¤Uµ{¦¡½X
    1. Public Class Form1
    2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    3.     End Sub
    4. End Class
    ½Æ»s¥N½X
  • §Ú­Ì¥i¥H¦b Button1_Click ³o­Óµ{§Ç¤¤¶ñ¤J
    1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         MessageBox.Show("HelloWorld")
    3.     End Sub
    ½Æ»s¥N½X
  • «öF5´N¥i°õ¦æ¤F


³oÅãµM¬O³Ì²³æªºµ{¦¡½X,MS ÅýWindowsFormµ{¦¡½XÅܱo²³æ,³o¬OÅý§Ú­Ì«Ü°ª¿³ªº,¥LÅý§Ú­Ì¤£¥Î¦A¥h·Ð´o¤¶­±ªº°ÝÃD,¦Ó¬Û¹ïªº§â®É¶¡¥Î¦b§Ú­Ì­n¸Ñ¨Mªº°ÝÃD¤W
WindowsForm,¦³µÛ¬üÄRªº¥~Æ[,©M³\³\¦h¦hªº±±¨î¶µ,Åý§Ú­Ì¥i¥H­É¥Ñ³o¨Ç¤w¶}µo¦nªº±±¨î¶µ¥u¸g¥Ñ³]©w¦Ó¤£¥Î¦A¼g¨ä¥¦ªºµ{¦¡½X´N¥i¹F¨ì¬Û·íªº¥\¯à,·íµM,¦b³o¨Ç±±¨î¶µªº­I«á
ÅãµM¦³µÛµL¼Æªºµ{¦¡½X,¦ý¨º¤£¬O§Ú­Ì­nÃö¤ßªº¤F,°£«D§A·Q­n¶}µo±MÄÝ©ó­Ó¤Hªº±±¨î¶µ,¨º§A¥i¥HÂмg¸Ó±±¨î¶µÃþ§O©ÎªÌ¬O¥¦ªº¤÷Ãþ§O©ÎªÌ¬O¯ª¤÷Ãþ§O......µ¥µ¥,¦ý¨º¬O¥t¥~¤@¦^¨Æ¤F
1

µû¤À¤H¼Æ

    • ¤p»x: ºë«~¤å³¹ª÷¿ú + 10

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

·í§Ú­ÌÁä¤JMessageBox. ªº®É­Ô,·|¦Û°Ê¥X²{ show³o­Ó¤èªk
¦ÓMessageBox©Ò¦³ªº¦¨­û¤]¥u¦³³o­Ó¤èªk,¦ý¹ê»Ú¤W,show ¨Ã¤£¬OMessageBoxªº¦¨­û
¦pªG±z¦³¥J²Ó¬Ýªº¸Ü,´N·|¬Ý¨ì , show ³o­Ó¨ä¹ê¬O¤@­Ó¤À¨É¨ç¼Æ(¦³¤HºÙ¤§¬°ÀRºA¨ç¼Æ)
¦pªG§Ú­Ì¬Ý¨ìshow ªº¼ÐÀY©w¸q,¥]§t¤Fshared³o­Ó¦r
public shared function show(..........) as dialogresult
´N¥i¥H¤F¸Ñ,³o­Ó¨ç¼Æ¨ä¹ê¥i¥Hª½±µ³z¹LÃþ§O¦s¨ú,¦Ó¤£¥Î³z¹L¹êÅé¦s¨ú
©Ò¥H§Ú­Ì¤£·|¼g³o¼Ëªºµ{¦¡½X    dim x as new messagebox
µM«á¦A¨Ó x.show , ³o¬O¿ù»~ªº
¥t¥~,show³o­Ó¨ç¼Æ¥i¥H¶Ç¦^ dialogresult ³o­Ó¼Æ­È, ¥¦¨ä¹ê¬O¤@­Ó±`¼Æ,§Ú­Ì·|¦b«á­±¥Î¨ì¥¦
¦AªÌ,show¨ä¹ê¬O¤@­Ó¦³20ºØ§ÎºAªº¦h¸ü¨ç¼Æ,¥¦Åý¤@­Ó¨ç¼Æ¥i¥H¦³¬Û¦Pªº¦WºÙ,«o¦³µÛ¤£¦Pªº¿é¤J¤è¦¡
³o¨Ï±o¦WºÙªº¨Ï¥Î¤W§ó¨ã¦³¼u©ÊªÅ¶¡,¦P¼Ëªº°Ê§@¦WºÙ,«o¦³ªÌ¤£¦Pªº§e²{¤è¦¡,³o¼Ëªº¤è¦¡,Åýµ{¦¡½Xªº
ºÞ²z§ó¥[ªº¤è«K,¥H¤U§Ú­ÌÁä¤J¤@­Ó¦h¸üªºshow ¤èªk
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  2.         If MessageBox.Show("MyFirstProgram", "WindowsForm ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes Then

  3.             MessageBox.Show("¦¨¥\")
  4.         End If

  5.     End Sub
½Æ»s¥N½X
·íµM¥u¦³§Ú­Ì¦b«ö¤Uyes¶s¤~·|°Ê§@,¦Ó«ö¤Uyes®É´N¦^¶Ç Windows.Forms.DialogResult.Yes,
WindowsForm´N¬O³o»òªºÂ²³æ

TOP

¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-9 12:56 ½s¿è

¼gµ{¦¡ªº²Ä¤@¨B´N¬O­n«Å§iÅܼÆ
visual basic ¥i¥HÅý§Ú­Ì¤£«Å§i
¦ý³o¤£¬O¼gµ{¦¡ªº¨}¦n²ßºD,ÅܼƳ̦n¬O«Å§i,Åývisual basic ¨ÓÀˬd¸ÓÅܼƬO§_¦Xªk
§Ú­Ì¥i¥H¦bµ{¦¡½Xªº³Ì¤W¤è¥[¤J
Option Explicit On ,¨Ó±j¨îµ{¦¡¼g§@­û«Å§i,
ÅܼƳ̦n¬O¦³·N¸qªº¦r,´Nºâ¬O¤¤¤å¤]¨SÃö«Y,¤]´N¬O»¡,¥þ³¡³£¥Î¤¤¤å¼g,¥u¦³ÃöÁä¦r©M«O¯d¦r¬O­^¤å¤]¨SÃö«Y
¦]¬°µ{¦¡¬O¼gµ¹¤H¬Ýªº,©Ò¥H¬O·U²³æ·U¦n,°£«D¦³µÛ¨ä¥¦¦]¯Àªºªº¦Ò¶q,¤£µM³Ì¦n¬O¼g¦¨¤@¬Ý´Nª¾¹D¦b¼g¤°»ò
§Q¦p:
  1. Option Explicit On
  2. Public Class Form1
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  4.         Dim ®É As Integer
  5.         Dim ¤À As Integer
  6.         Dim ¬í As Integer

  7.         ®É = Now.Hour
  8.         ¤À = Now.Minute
  9.         ¬í = Now.Second
  10.         MessageBox.Show("²{¦b®É¨è" & ®É & " ®É " & ¤À & " ¤À " & ¬í & "¬í")
  11.     End Sub
  12. End Class
½Æ»s¥N½X
¤W­±ªºµ{¦¡½X¤¤ Dim ®É As Integer ´N¬O«Å§i,¦ÓÅܼƪº©Ê½è´N¬O¾ã¼Æ,¾ã¼Æ¬O¤@ºØ«¬§O,»¡«¬§O¦n¹³¦³¤@ÂI±M·~,§Ú­Ó¤H¤@¦V¤£³ßÅw±M·~,¦]¬°±M·~¦n¹³¬O­nÅý¤HÅ¥¤£À´
§A¥i¥H·Q¹³¦¨¬O¤@ºØ¤ÀÃþ,§â¦UºØ¤£¦PªºªF¦è¥[¥H¤ÀÃþ,´N¬O¼gµ{¦¡ªº°ò¦,¦Ó¥B¤]¬O¤@ºØºÞ²z
¨º»òvisual basic ¦³¦h¤ÖºØÃþ¦ü©ó¾ã¼Æªº³oºØ¤ÀÃþ,¥H¤Uµy°µ¾ã²z

  • string ¦r¦ê                       
  • char ¦r¤¸
  • byte ¦ì¤¸²Õ
  • sbyte ¦ì¤¸²Õ
  • short µu¾ã¼Æ
  • integer ¾ã¼Æ
  • long ªø¾ã¼Æ
  • Decimal
  • single ³æºë«×¯BÂI¼Æ
  • double Âùºë«×¯BÂI¼Æ
  • date ¤é´Á
  • boolean ¥¬ªL
  • object ª«¥ó

·íµM¬Ý¤F¥H¤Wªº«Å§i´Nª¾¹D§Ú­Ì³£¥i¥H¼Ò¥é,§Q¦p
dim x as string
´N¬O«Å§i¤@­Ó¦r¦ê
dim x  as single
´N¬O«Å§i¤@­Ó³æºë«×ªº¯BÂI¼Æ
©Ò¿×ªº¯BÂI¼Æ´N¬O¥i¥H±a¦³¤p¼ÆÂI¥H¤Uªº¼Æ¦r
©ÎªÌ§Ú­Ì¤]¥i¥H³o¼Ë«Å§i,§Q¥Î","¤À¶}¤£¦P¸ê®Æ«¬ºAªº¨Ó«Å§i
¨Ò¦p: dim x as single, y as double, z as decimal
·íµM§Ú­Ì¤]¥i¥H¤@¶}©l´Nµ¹Åܼƫü©w­È
¨Ò¦p dim x as single = 3.5,y as string = "Hello World"
¥t¥~,§Ú­Ì¥i¥H¥[µù¸Ñ¨ìµ{¦¡½X¤¤,¦Ó½sĶ®É,½sĶ¾¹´N¤£·|¥h²z·|³o­Óµù¸Ñ,µù¸Ñªº²Å¸¹´N¬O '

§Q¦p
dim y as date ' y ¬O ¤é´Áªº«¬ºA
¦b ' ²Å¸¹«á­±ªº¤å¦r·|³Q©¿²¤, Åý§Ú­Ì¥i¥H¥Î¨Ó°O¿ý¤@¨Çµ{¦¡½Xªº¥Øªº,©Î¬O¨ä¥¦­n¨Æ

TOP

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

§Ú­Ì´N¨Ó¬Ý¬Ý´XºØ¸ê®Æ§ÎºAªº¾Þ§@¤è¦¡

  • Byte ¹ê»Ú¤W¬O¤@­Ó¦û¥Î¤@­Óbyte°O¾ÐÅ骺¾ã¼Æ­È,¨ä½d³ò¬O0~255 ¤]´N¬O 2 ªº 8 ¦¸¤è = 256 ­Ó¦ì¸m
    ¥ô¦ó¶W¹L³o­Ó½d³òªº¾ã¼Æ­È³£·|²£¥Í¤@­Ó·¸¦ìªº¨Ò¥~,¨Ò¦p
    1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim x As Byte
    3.         x = 255
    4.         x = x + 1
    5.         MessageBox.Show(x)
    6.     End Sub
    ½Æ»s¥N½X
    ¦pªG§A¬O¤@¶}©l´N«ü©w x = 256 , ¨º½sĶ¾¹´N¨Sªk½sĶ(²{¥Nªº½sĶ¾¹¤]°µ±o¤Ó¥D°Ê¤F)
  • SByte ³o­Ó¸ê®Æ«¬ºA¤]¬O¤@­Ó¦û¥Î¤@­Óbyte°O¾ÐÅ骺¾ã¼Æ­È,¤£¹L©w¸qªº½d³ò¬O−128 ¨ì 127,¦]¬°¥L¥i¥H¦s¨ú¦³±a­t¼Æªº²Å¸¹
    ©Ò¥H²Ä¤@­Óbit¨ä¹ê¨Óªí²{¼Æ­Èªº¥¿­tªº,¦Ó0³o­Ó¼Æ¦b³o¸Ì³Q©w¸q¬°¥¿¼Æ¦]¦¹²Ä¤@­Óbit´N¬O0(³o¸Ìªº0©M¼Æ¾Ç¤Wªº©w¸q¬O¤£¤@¼Ëªº)
  • Short  ©ÎªÌ¬O .NetFramework ¤¤ªº Int16 ,¸Ó«¬ºA¦û¥Î¤G­Óbytes°O¾ÐÅéªÅ¶¡,©w¸q¬°±q−32,768 ¨ì 32,767 ªº³sÄò¾ã¼Æ
  • Integer ©ÎªÌ¬O .NetFramework ¤¤ªº Int32 ¸Ó«¬ºA¦û¥Î¥|­Óbytes°O¾ÐÅéªÅ¶¡,©w¸q¬°±q−2,147,483,648 ¨ì 2,147,483,647ªº³sÄò¾ã¼Æ
  • Long ©ÎªÌ¬O .NetFramework ¤¤ªº Int64  ¤@­Ó¦û¥Î8 bytes°O¾ÐÅéªÅ¶¡,½d³ò±q−9,223,372,036,854,755,808 ¨ì 9,223,372,036,854,755,807
    ªº³sÄò¾ã¼Æ
  • UShort  ¤@­Ó¦û¥Î2 bytes°O¾ÐÅ骺ªÅ¶¡,½d³ò±q 0 ¨ì 65,535 ªº³sÄò¾ã¼Æ
  • UInteger  ¤@­Ó¦û¥Î 4 bytes°O¾ÐÅ骺ªÅ¶¡,½d³ò±q 0 ¨ì 4,294,967,295 ³sÄò¾ã¼Æ
  • ULong  ¤@­Ó¦û¥Î 8 bytes°O¾ÐÅ骺ªÅ¶¡,½d³ò±q 0 ¨ì 18,446,744,073,709,551,615 ³sÄò¾ã¼Æ
  • Single  ¤@­Ó¦û¥Î 4 bytes°O¾ÐÅ骺ªÅ¶¡,¥iªí¥Ü­t¼Æ−3.402823E38 ¨ì −1.401298E-45 ,¥¿¼Æ1.401298E-45 ¨ì 3.402823E38,0µLªkºë·Çªí¥Ü
    ,¥i¥H¬O«D±`¤p,¦ý¤£¬O0
  • Double  ¤@­Ó¦û¥Î 8 bytes°OÅéªÅ¶¡,¥iªí¥Ü­t¼Æ−1.79769313486232E308  ¨ì −4.94065645841247E-324
         ¥¿¼Æ4.94065645841247E-324 ¨ì 1.79769313486232E308
    ¤p¼Æ¹Bºâ¤@ª½¬O¹q¸£ªº°ÝÃD©Ò¦b,¦]¬°¦b¦U­Ó¶i¦ì¶¡µLªk¶i¦æ§¹¥þªºÂà´«,¥H¤U¨Ò¤l
    1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim x As Single
    3.         x = 1 / 3
    4.         MessageBox.Show(x * 100000)
    5.     End Sub
    ½Æ»s¥N½X
    Åã¥Ü¥X33333.34 ,©M§Ú­Ìªº´Á±æ¤£¦X, ©Î³\¦³¤H¬O¥i¤¹³\ªº,¦ý¹ê»Ú¤Wºë«×¬O®t«Ü¦hªº
    ¦]¦¹§Ú­Ì¥i¯à·|§Q¥Îdoubleºë«× ,ÁÙ¦³¤@ÂI¬O,¦pªG§A¥Î¤p¼Æ¨Ó°µ°j°éªºindex­p¼Æ,«Ü®e©ö¥X¿ù¦ý·|§ä¤£¨ì¿ù»~,³oºØ¨Æ´N´¿µo¥Í¹L
    ¨Ò¦p
    1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    2.         Dim x As Single
    3.         Dim count As Integer
    4.         x = 1

    5.         While x < 1.00001
    6.             x = x + 0.000001
    7.             count += 1
    8.         End While

    9.         MessageBox.Show(count)

    10.     End Sub
    ½Æ»s¥N½X
    ³oÀ³¸Ó­n¶]´X¦¸

  • Decimal ¹ê»Ú¤W³o¬O¤@­Ó¦û¥Î16 bytes °O¾ÐÅ骺¼Æ­È,¦Ó¥B¬O¤@­Ó¥H10¬°©³ªº«ü¼Æ¨ç¼Æ¨Ó¶i¦æ¤ñ¨Ò½Õ¾ã,¬Ý°_¨Ó¤Ó¼Æ¾Ç¤Æ¤F,Á|­Ó¨Ò¤l
    1. Option Strict On
    2. Option Explicit On
    3. Public Class Form1
    4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    5.         Dim a As Decimal = 5262.2358D
    6.         Dim b As Decimal = 12.62354D
    7.         Dim c As Decimal
    8.         c = a * b
    9.         MessageBox.show(c.ToString)
    10.     End Sub
    11. End Class
    ½Æ»s¥N½X
    ¹ê»Ú¤W a ³o­Ó¼Æ­È ¦b«ü©w¬°5262.2358®É¦pªG¤£¥[D¨º¹ê»Ú¤W¬O·|¥H¤º©w¬°doubleªº«¬ºA¨Ó«ü©w,¦Ó³o¼Ëªº¸Ü´N·|µo¥Í«¬ºA¨S¦³Âà´«¦Ó§Î¦¨¿ù»~
    ,¦Ó¥B·í½sĶ¾¹¶}©l®É·|±Na­¼¤W10ªº4¦¸¤èÅܬ°52622358¾ã¼Æ,¤@¼Ëªº12.62354·|­¼¤W10ªº5¦¸¤è«K¬°¾ã¼Æ,¦A¶i¦æ¬Û­¼,±o¨ìµ²ªG«á¦A°£©ó10ªº9¦¸¤è¨Ó±o¨ìµª®×
  • Boolean ¥¬ªL, ¤£¬Otrue(-1) ´N¬O False(0)
  • Date ¤é´Á
    1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim date1 As Date = #1/1/2010#
    3.         Dim date2 As Date = #1/2/2010#
    4.         MessageBox.Show((date2 - date1).ToString)
    5.     End Sub
    ½Æ»s¥N½X
  • Char ¦r¤¸ ¨ä«Å§i¤è¦¡©M«ü©w¤è¦¡¦p¤U
    1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim x As Char = "a"c
    3.         MessageBox.Show(x)
    4.     End Sub
    ½Æ»s¥N½X
  • String ¦r¦ê
  • ³Ì«á¤@ºØ«¬ºA§Ú­Ì¤¶²Ð¤@¤U,¥s¨Ï¥ÎªÌ¦Û©w«¬ºA,
    ³oºØ«¬ºA¸g¹L¤Fµ{¦¡»y¨¥ªº´X¦¸ÅÜ­²,³Ì«á²×©ó½T©w¤F¦WºÙ
    ¥s°µÃþ§O,Ãþ§O¬Oª«¥ó¾É¦Vªº°ò¦,¦bWindowsForm¤¤,§A¤@©w¬O¦bÃþ§O¤º¼gµ{¦¡
    1. Public Class Form1
    2. End Class
    ½Æ»s¥N½X
    ¹ï§a,§Aªºµ{¦¡½X¬O¼g¦bForm1¤º§O¤º
    ¨ì¤F¤µ¤Ñ,´X¥G¨S¦³¤@ºØ¶}µo«¬ªºµ{¦¡»y¨¥¤£¬Oª«¥ó¾É¦V¦¡ªº,§Ú«üªº¬O¦U¥D­n¬y¦æªºµ{¦¡»y¨¥¦Ó¨¥
    §Q¦p
    c ---> c++ (c with class) ,³o·íµM¬O¤GºØ¤£¦P»y¨¥
    , .net ªº©Ò¦³¶}µo»y¨¥À³¸Ó³£¬O(Å¥»¡¦³fortran,¦ý¤£ª¾¦³µL¤ä´©)
    ·íµM,visual basic.net ©M¥H«eªºvisual basic6 ¤w¸g§¹¥þ¤£¦P,
    ¨º»òª«¥ó¾É¦V¦³¦ó¥Î³B,¬°¤°»ò¬Oµ{¦¡»y¨¥ªº¬y¦æÁͶÕ
    ¨º¬O¦]¬°,ª«¥ó¾É¦V¨Ï±o§Ú­Ì¼gµ{¦¡ªº¤è¦¡§ó¬°±µªñ¤HÃþªº«ä¦Ò¼Ò¦¡
    §Ú­Ì¤£¥Î¦b¥h¦Ò¼{¨º¨Ç´²¦b¦U¦aªºµ{¦¡½X¦p¦ó¨ú±o,©ÎªÌ¬O¤w¸g³Q§Ú­Ì¿ò§Ñªº,¥u­n¬O¤@¬Ý¦r­±´N¥i¥Hª¾¹D¦p¦ó¨Ï¥Î
    ,¦]¬°¥L¬O°Ñ¦Ò¤H­Ì¦b²{¹ê¨Æ¬ÉÆ[¹î¨Æª«±o¨ìªººÞ²z¼Ò¦¡
    ¨Ò¦p,§Ú­Ì¦b°Ý¸ô®É,³q±`³Q°Ýªº¤H·|»¡,²Ä´X­Ó¬õºñ¿O­n¥ªÂà,³o´N¬Oª«¥ó¾É¦V
    ²Ä´X­Ó¬õºñ¿O´N¦³¬õºñ¿O©M¼Æ¦r,§A§â¼Æ¦r©M¬õºñ¿Oµ²¦X¤F´N¬O§AÄ~©Ó¤F¬õºñ¿O¥~¥[¤W¤@­Ó½s¸¹
    ´N³o»ò²³æ,¨S¤°»ò¯«¯µ¤§³B,¦A«ç»ò¤j«¬ªºµ{¦¡½X,³£ÁÙ¬O¥Ñ³Ì¤pªº³æ¦ì²Õ¦¨,¦³µÛ³Ì²³æªº²Ó³¡

    ¨º»ò§Ú­Ì§â¤W­±ªºµ{¦¡§ï¼g¤@¤U´NÅܦ¨¤F
    1. Public Class Form1
    2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.         Dim ®ÉÄÁ As New ®ÉÄÁ

    4.         MessageBox.Show("²{¦b®É¨è" & ®ÉÄÁ.®É & "®É" & ®ÉÄÁ.¤À & "¤À" & ®ÉÄÁ.¬í & "¬í")

    5.     End Sub

    6. End Class

    7. Public Class ®ÉÄÁ
    8.     Inherits Object

    9.     Public ReadOnly Property ®É() As Integer
    10.         Get
    11.             Return Now.Hour
    12.         End Get
    13.     End Property

    14.     Public ReadOnly Property ¤À() As Integer
    15.         Get
    16.             Return Now.Minute
    17.         End Get
    18.     End Property

    19.     Public ReadOnly Property ¬í() As Integer
    20.         Get
    21.             Return Now.Second
    22.         End Get
    23.     End Property
    24. End Class
    ½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-9 10:31 ½s¿è

¤]´N¬O§Ú­Ì´N¦Û¤v©w¤F¤@­Ó®ÉÄÁÃþ§O,¥L¥i¥H¦³®É,¤À,¬í,¦Ó³o­ÓÃþ§O¹ê»Ú¤WÄ~©Ó¤Fobject³o­Ó©Ò¦³Ãþ§Oªº¦Ñ¯ª©v,§A¤£¼g¤]¥i¥H
´N¬O³o¤@¥y    Inherits Object    ' Ä~©Ó¦Û ª«¥ó
¦ý³o¬O¥H®ø¶OªÌªºÆ[¹î¦Ó¨¥,¥L¥u¬O·Q­n¬Ý¨ì¥L·Q­n¬Ýªºªº¸ê°T,§Ú­nªº¬O´XÂI´X¤À
¨º´N¥Í²£ªÌ¦Ó¨¥¥i´N¤£¬O³o»ò¦^¨Æ,®ÉÄÁ¦³ªÌ«Ü¦hªº¹s¥ó,®É°w,¤À°w,¦UºØÁ³µ·
,¨º»ò¥L¥i¯à¹ï©ó³o»ò²³æªº¸ê®Æ¤£º¡·N,¦]¦¹¥L·Q§ï¼g³o­ÓÃþ§O,¦ý¬O¦³®É­Ô³Ì¥O¤HÀYµhªº¬O¥L¨S¦³
³o­ÓÃþ§Oªº­ì©l½X,¦Ó¥u¦³dll,¹ï¥L¦Ó¨¥,³Ì¤è«Kªº´N¬O§ï¼g,»s³y°Ó·Q°µ¤@­Ó³ø®É¶s , ¥L©Ò­n°µªº¨Æ¬O³o¼Ë,¥H¤U¬Oµ{¦¡½X
  1. Public Class ·|³ø®Éªº®ÉÄÁ

  2.     Inherits ®ÉÄÁ

  3.     Public Function ³ø®É() As String

  4.         Return "²{¦b®É¨è" & Me.®É & "®É" & Me.¤À & "¤À" & Me.¬í & "¬í"

  5.     End Function
  6. End Class

  7. Public Class Form1

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

  9.         Dim ®ÉÄÁ As New ·|³ø®Éªº®ÉÄÁ

  10.         MessageBox.Show(®ÉÄÁ.³ø®É)
  11.     End Sub


  12. End Class
½Æ»s¥N½X
³o¼Ë,§Ú­Ì«Ü²M·¡ªº¬Ý¨ì,§Ú­Ì¥u­nÄ~©Ó­ì¥»ªº®ÉÄÁÃþ§O,´N¬O±o¨ì¤@­Ó·sªº³ø®É®ÉÄÁ,³o­Ó®ÉÄÁ¦³¤@­Ó¥\¯à,©ÎªÌºÙ¤§¬°¨ç¼Æ,¥L³Q¥]¦b®ÉÄÁ¤§¤¤¤F
©M¤W­±µ{¦¡½X¤£¦Pªº¬O,¦pªG§Ú­Ì¬O±q¥~¬É¬Ý®ÉÄÁ,¨º´N·|¼g¦¨¤£·|³ø®Éªº®ÉÄÁ¼Ë¦¡,¦ý¦pªG¬O®ÉÄÁ¥i¥H³ø®É,¨º´N·|¼g¦b®ÉÄÁÃþ§O¤¤¦Ó¦¨¬°·|³ø®Éªº®ÉÄÁÃþ§O
´N¬O³o»ò²³æ
Function ³o­Ó´N¬O¨ç¼Æ´N·N«ä,¦Ó¨C­ÓFunction ¤§§¹µ²·|¦³End Function
ªí¥Ü³o­Ó¨ç¼Æ¨ì¦¹²×µ²
¨º»ò±q¥~¬É¨Ó¬Ý³o­Óµ{¦¡½X¬O¤£¬O´N¬O¦¨¤F    Dim ®ÉÄÁ As New ·|³ø®Éªº®ÉÄÁ ' §Ú²£¥Íªº¤@­Ó·|³ø®Éªº®ÉÄÁ
MessageBox.Show(®ÉÄÁ.³ø®É)   '®ÉÄÁ³ø®É

TOP

¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-13 01:02 ½s¿è

¤W­±ÁÙ¦³´XÂI¬O­n¸É¥Rªº
vb.net ¹ï©ó¨ç¼Æ©Mµ{§Çªº¤è§O
¨ç¼Æ¬O¥i¥H¶Ç¦^­Èªº,¦Óµ{§Ç¤£¯à
¨ç¼Æ³Ì«áªº¶Ç¦^­È»yªk¥i¥H¬O return ¬Y¤@­Ó­È
©ÎªÌ¬O ¨ç¼Æ©w¸q = ¬Y¤@­Ó­È
¨Ò¦p Return "²{¦b®É¨è" & Me.®É & "®É" & Me.¤À & "¤À" & Me.¬í & "¬í"
¤]¥i¥H¼g¦¨  
³ø®É = "²{¦b®É¨è" & Me.®É & "®É" & Me.¤À & "¤À" & Me.¬í & "¬í"
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  2.     End Sub
½Æ»s¥N½X
³o´N¬O«ö¶sªºµ{§Ç­ì«¬ ,¥¦¤£·|­n¨D¶Ç¦^­È
  1. Public ReadOnly Property ®É() As Integer

  2.         Get

  3.             Return Now.Hour

  4.         End Get

  5.     End Property
½Æ»s¥N½X
¥t¥~³o­ÓºÙ¤§¬°ÄÝ©Ê,¥¦Åý§Ú­Ì¥i¥H¦s¨ú¨ç¼Æ¹³¦b¦s¨úÅܦ¬¨º¼Ëªº¦ÛµM

¨ºwindowsform ¬OÃþ§Oªº¸Ü,¨º¥L¬OÄ~©Ó¦Û object ¶Ü
  1. Public Class Form1

  2. End Class
½Æ»s¥N½X
¨Ã¨S¦³¥ô¦óªºÄ~©Óªº¼Ë¦¡,³o¨ä¹ê¬O MS ¬°¤FÅý¨Ï¥ÎªÌ±q¥~Æ[¤W¬Ý¨Ó¹³¬O¦^¨ì¤Fvisual basic6ªº«¬ºA
¹ê»Ú¤W§A¦b¤è®×Á`ºÞ¤¤Form1.desinger.vb¤¤,¥i¥H¬Ý¨ì
  1. Partial Class Form1
  2.     Inherits System.Windows.Forms.Form
  3. End Class
½Æ»s¥N½X
visual basic ¦³¥t¥~¤@ªÌ¨Ï¥ÎªÌ¦Û©w«¬ºA,ºÙ¤§¬°µ²ºc,¨ä¨Ï¥Î¤è¦¡©Mclass¤j¦P¤p²§,´N¥\¯à¤W¦Ó¨¥,µ²ºcµLªkÄ~©Ó,³o´N¬Oµ²ºc©MÃþ§O³Ì¤jªº¤£¦P³B
¤£¯àÄ~©Ó´N¥Nªíªº¬O¤£¯àÂмg,¤£¯à¼W¥[ÄÝ©Ê,¤]´N¬O»¡±z¨Sªk¦bStructure¤¤¥[¤J¥iÂмgªº¨ç¼Æ©Îµ{§Ç,¦ý¦³½ìªº¤@ÂI¬O,±z¥i¥HÂмgvb¤¤ªº¤@¨Ç°ò¥»¤èªk,
¦ptostring,gethashcod,equals,³o¨Ç¬O¤º©wªº,°£¦¹¤§¥~,¨ä¥¦ªºÀ³¸Ó³£¤£¯àÂмg
¦]¦¹µ²ºc¥u¯à¹F¨ì¸ê®Æªº«Ê¸Ë¥\¯à,¦ýµ²ºcÁÙ¬O¦³¥L¦s¦bªº¥²­n,¦]¬°µ²ºc¬O­È«¬§O,¦Ó¤£¬O°Ñ·Ó«¬§O,¦]¦¹
¥L¨Ã¤£¬O²£¥Í¦b°ï¿n¤§¤W,¦ÓÃþ§O¬O°Ñ·Ó«¬§O,¤@¨Ç¸û¤pªº«¬ºA§Q¥Î­È«¬§O¬O¤ñ¸û§Öªº,©Ò¥H¥LÁÙ¬O¦³¦s¦bªºªº¥²­n
¥H¤UÁ|¤@­Ó­È«¬§Oªº¨Ò¤l:
  1. Public Class Form1

  2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         Dim ­û¤u¥Ò As ­û¤u

  4.         With ­û¤u¥Ò
  5.             .¦~ÄÖ = 35
  6.             .©m¦W = "¬öxx"
  7.             .©Ê§O = "¤£¨k¤£¤k"

  8.             MessageBox.Show(.©m¦W & "ªº¦~ÄÖ¬O" & .¦~ÄÖ & ",¦Ó©Ê§O¬O" & .©Ê§O)
  9.         End With

  10.     End Sub
  11. End Class

  12. Public Structure ­û¤u
  13.    Public ©m¦W As String
  14.     Public ¦~ÄÖ As Integer
  15.     Public ©Ê§O As String
  16. End Structure
½Æ»s¥N½X

TOP

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

«¬§OªºÂà´«
§Ú­Ì®É±`³£­n«¬§OªºÂà´«
§Q¦p,integerÂàdouble©ÎªÌ¬OÂàstring
©ú½TªºÂà´«¦³§U©ó®Ä¯àªº´£¤É,visualbasic ¤¹³\µ{¦¡¼g§@®É¤£¥Î©ú½TÂà´«
¥u­n±z¦bµ{¦¡Àɳ̤WÀY¥[¤W
Option Strict Off
¦ý³o¨Ã¤£³Q«Øij³o¼Ë°µ,«¬§OªºÀˬd©MÂà´«¬O¦³§U©ó¨¾¤î¨Ò¥~µo¥Íªº
visual basic ¤º«Ø¤F«Ü¦h«¬§OÂà´«ªº¨ç¼Æ,¦pCint,CDbl,³o¨Ç¨ç¼Æ¬O¦bvisual basic6´N¦s¦bªº¨ç¼Æ¦WºÙ
³o¸Ì§Ú­Ì¤¶²Ð¤@¤U Convert Ãþ§O¤ºªº¤À¨É¤èªk
  1. Option Strict On
  2. Option Explicit On
  3. Public Class Form1
  4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  5.         MessageBox.Show(Convert.ToString(1 / 7))
  6.         MessageBox.Show((Convert.ToInt32(1 / 7)).ToString)
  7.         MessageBox.Show((Convert.ToSingle(1 / 7)).ToString)
  8.     End Sub
  9. End Class
½Æ»s¥N½X
·íµM³o­ÓÃþ§O¤ºÁÙ¦³¨ä¥¦ªº¤À¨É¤èªk,´NÅý±z¦Û¤v¥h¸ÕÅç,¦ý¥Ñtostring¤èªk´N¥i¥Hª¾¹D,©Ò¦³ªº«¬§O´X¥G³£¹ê§@¤Ftostring¤èªk
¦]¦¹convert.tostring¤èªk¦ü¥G³£Åã±o¦h¾l¤F
,¦ý³o¨Ç¬OÄÝ©ó°ò¥»«¬§OªºÂà´«¤u§@,visual basic ¦b«¬§O¤W¤S¤À¬°¤G¤jÃþ
¤@­ÓºÙ¤§¬°­È«¬§O,¥t¤@­ÓºÙ¤§¬°°Ñ·Ó«¬§O,¹³integer,double³oºØ°ò¥»«¬§OºÙ¤§¬°­È«¬§O
¦Ó§Ú­Ì¥ÎÃþ§O©Ò«Ø¥ßªººÙ¤§¬°°Ñ·Ó«¬§O,§Q¦p WindowsForm¤¤ªº¦UºØ±±»s¶µ³£¬O°Ñ·Ó«¬§O
­È±o¤@´£ªº¬O string ¹ê»Ú¤W¬O°Ñ·Ó«¬§O,¦ý°ò©ó²ßºD,ms¨Ï¥Î¤@¨Ç°Ê§@,Åý¥Lªº¼g§@»yªk¬Ý°_¨Ó©M­È«¬§O¤@¼Ë
¦Ó¤@¯ë°Ñ·Ó«¬§O¤§¶¡ªºÂà´«¬O¥Î directcast ¨ç¼Æ¨ÓÂà´«,´N¹³¥H¤U³o¼Ë
  1. Option Strict On
  2. Option Explicit On

  3. Public Class Form1

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

  5.         DirectCast(sender, Button).Text = "Âà´«¦¨¥\"
  6.       
  7.     End Sub
  8. End Class
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-15 13:19 ½s¿è

¥iµø½d³ò(scope):
·í§Ú­Ì«Å§i©Î©w¸q®É®É±`·|¬Ý¨ì  public ...... ,private..... ,³o¨Ç³QºÙ¤§¬°­×¹¢¤l
·í§Ú­ÌªºÅܼƦbµ{§Ç¤º®É¤£·|¥Î pulic ³oµ{­×¹¢¤l,§Ú­Ì¥u·|¥Î  dim ¨Ó «Å§i
¸ÓÅܼƨ䣯à³Q³o­Óµ{§Ç©ÎªÌ¬O¨ç¼Æ¥H¥~µ{§Ç©Î¨ç¼Æ©Ò¦s¨ú
·í§Ú­ÌªºÅܼƩΪ̬O¨ç¼Æ,µ{§Ç¦bÃþ§O¤¤©Î¬Oµ²ºc¤¤,©Î¬O¼Ò²Õ¤¤,¥u­n¬O«eÀY³Q¥[ private ¨º´Nªí¥Ü
³o­ÓÅܼƩε{§Ç,¨ç¼Æ¥u¯à¦b¸ÓÃþ§O,µ²ºc,¼Ò²Õ¤¤¦s¨ú,¦ÓµLªk¥Ñ¥~³¡¦s¨ú¸ÓÅܼƩε{§Ç©Î¤èªk
¤Ï¤§¦pªG¬Opublic,´N¥i³Q¥~­å¦s¨ú,§Ú­Ì´N®ÉÄÁ©Mform1Ãþ§O¨Ó»¡,form1¬Opublic,©Ò¥H¥i¥H³Q¨ä¥¦ªºÃþ§O¦s¨ú
¦ÓSub Button1_Click ¬Oprivate ,©Ò¥H¥u¦bform1Ãþ§O¤º©I¥s
Button1_Clickµ{§Ç¤ºªº ®ÉÄÁÅܼƫŧi¬O¥Îdim(¤]¥u¯à¥Îdim ,¦]¬°public ,private ¤£±o¥Î©óµ{§Ç©Î¨ç¼Æ¤º), ©Ò¥H¥u¯à¦bµ{§Ç¤º¨Ï¥Î
¦Ó®ÉÄÁÃþ§O¤º¦³¤T­ÓÄݩʳ£¬Opublic,¦ý¦bpublic ¤§«á¤S,¦³readonlyªí¬O¥u¯àŪ,¤£¯à¦s,©Ò¥H¤T­ÓÄݩʳ£¥i¥H³Q¨ä¥¦Ãþ§OŪ¨ú(¤£¯à¦s)
  1. Public Class Form1
  2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         Dim ®ÉÄÁ As New ®ÉÄÁ

  4.         MessageBox.Show("²{¦b®É¨è" & ®ÉÄÁ.®É & "®É" & ®ÉÄÁ.¤À & "¤À" & ®ÉÄÁ.¬í & "¬í")

  5.     End Sub

  6. End Class

  7. Public Class ®ÉÄÁ
  8.     Inherits Object

  9.     Public ReadOnly Property ®É() As Integer
  10.         Get
  11.             Return Now.Hour
  12.         End Get
  13.     End Property

  14.     Public ReadOnly Property ¤À() As Integer
  15.         Get
  16.             Return Now.Minute
  17.         End Get
  18.     End Property

  19.     Public ReadOnly Property ¬í() As Integer
  20.         Get
  21.             Return Now.Second
  22.         End Get
  23.     End Property
  24. End Class
½Æ»s¥N½X
¥Í©R¶g´Á
¤@­ÓÅܼƦbµ{¦¡¤¤«O¦³¥Lªº­Èªº®É¶¡´N¥s°µ¥Í©R¶g´Á,¤@¯ë¦Ó¨¥,¤@­Óµ{§Ç©Î¨ç¼Æ°õ¦æ§¹®É,¸Ó¨ç¼Æ©Îµ{§Çªº©Ò¦³ÅܼƴN¤£¦s¦b¤F,³o¨ÇÅܼƦs¦bªº®É¶¡´N¥u¦³¤@­Ó¨ç¼Æ°õ¦æªº®É¶¡
¦ý¦pªG¬O¥þ°ìÅܼÆ,¦p§Q¥Îpublic ©Îprivate ³o³o­×¹¢¤lªºÅܼÆ,¥L­Ì¦s¦bªº®É¶¡´N¬O¤@¾ã­ÓÃþ§O©Î¬OÀ³¥Îµ{¦¡¦s¦bªº®É¶¡,¦]¦¹·í§Ú­Ì­n¤@­ÓÅܼƦb¤@­Óµ{§Ç¤¤°õ¦æ§¹®ÉÁÙ­n«O¯d¥Lªº­Èªº®É­Ô,³q±`´N·|¨Ï¥Î¥þ°ìÅܼÆ
try ¬Ý¬Ý¤U­±¤G­Óµ{¦¡½X
  1. Public Class Form1

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

  3.         Dim x As Integer
  4.         x = x + 1

  5.         MessageBox.Show(x)

  6.     End Sub

  7.     Private y As Integer
  8.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

  9.         y = y + 1
  10.         MessageBox.Show(y)

  11.     End Sub

  12. End Class
½Æ»s¥N½X
§Ú­Ì«Ü²M·¡¥i¥H¬Ý¨ì¨C«ö¤@¦¸button2¶s,yªº­È´N·|¼W¥[1,¦ý«öbutton1¶s,x­È¨C¦¸ªº­È³£¬O1,³o´N¬O¦]¬°¥þ°ìÅܼƤ£¦]µ{§Çµ²§ô´N®ø¥¢,©Ò¥Hyªº­È¨C·í«ö¤@¦¸¶s
µ²§ôµ{§Ç¾Þ§@®É´N·|¥[1,¦ý¦³®É­Ô§Ú­Ì¤£·QÅýÅý§Oªºµ{§Ç¤]¦s¨ú¨ìy,¤G­Óµ{§Ç¦P®É­×§ï¨ìy­È³y¦¨µLªk¹w´Áªºµ²ªG¦p¤U
  1. Public Class Form1

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

  3.         y = y + 1

  4.         MessageBox.Show(y)

  5.     End Sub

  6.     Private y As Integer

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

  8.         y = y + 1
  9.         MessageBox.Show(y)

  10.     End Sub
  11. End Class
½Æ»s¥N½X
³o¼Ë¤£ºÞ§Ú­Ì«ö button1 ©Î¬O button2 y­È³£·|¥[1,§Ú¥u·Q§ây­È·í¦¨µ{§Ç¤ºªºÅܼÆ,¦ý¤S·Q«O¯d¨ä­È,¨ºÀ³¸Ó«ç»ò°µ
¦³¤@µ{¥sÀRºAÅܼƪºªF¦è ¨ä»yªk¦p¤U
Static ÀRºAÅÜ¼Æ as «¬ºA
¥i¥HÅý§A«Å§i¦bµ{§Ç¤ºªºÅܼƤ]¥i¥H«O¯d¨ä­È¥H¤U¬°½d¨Ò
  1.    
  2. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  3.         Static y As Integer
  4.         y = y + 1
  5.         MessageBox.Show(y)
  6.     End Sub
½Æ»s¥N½X
¥t¥~,¦³¤@µ{ÅܼƳQºÙ¤§¬°±`¼ÆªºÅܼÆ,³oºØÅܼƤ£½×§A¦p¦ó§ïÅÜ¥L³£¨S¥Î,¥L¬O¤@¶}©l«Å´N¤@©w­n³]©w°_©l­È,¥H«á§¡¤£¥iÅÜÅÜ
§_«h·|¦³¿ù»~°T®§,¸ÓÅܼƫŧi¤è¦¡¦p¤U
Const x As Integer = 23
¨º x  ´N¬O¤@­Ó±`¼Æ,¦Ó¥B¥²»Ý­nµ¹°_©l­È23,³o­Ó­È´N¤@ª½·|¬O23

TOP

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

°}¦C
·í§Ú­Ì­n«Å§i¤@°ïÅܼƦӥB¬O¦P¤@©Ê½èªº,§Ú­Ì·|¥L­Ì¶°¦X¦b¤@°_¥Î¤@­Ó®e¾¹µ¹¥L­ÌµM«á³o­Ó®e¾¹¦³¤j¤p,³oºØ®e¾¹ºÙ¤§¬°°}¦C
§Q¦p ¦r¦ê¥Ò,¤A,¤þ,¤B ¤£·|¥h³o¼Ë«Å§i
dim ¦r¦ê¥Ò as string
dim ¦r¦ê¤A as string
dim ¦r¦ê¤þ as string
dim ¦r¦ê¤B as string
§Ú­Ì·|«Å§i¤@­Ó°}¦C,¨ä¤è¦¡¦p¤U
dim ¦r¦ê¶°¦X(3) as string
3´N¬O³o­Ó¦r¦ê°}¦C¯Á¤Þªº ¤W­­
¦Ó³o­Ó¦r¦ê°}¦Cªº¯Á¤Þ¤U«Ü´N¬O0,©Ò¥H¾ã­Ó¦r¦ê°}¦Cªº¦r¥i¦s¨ú­Ó¼Æ¬°0~3,¦@¦³¥|­Ó
Á|­Ó§Q¤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 ¤@¬P´Á(6) As String
  4.         ¤@¬P´Á(0) = "¬P´Á¤é"
  5.         ¤@¬P´Á(1) = "¬P´Á¤@"
  6.         ¤@¬P´Á(2) = "¬P´Á¤G"
  7.         ¤@¬P´Á(3) = "¬P´Á¤T"
  8.         ¤@¬P´Á(4) = "¬P´Á¥|"
  9.         ¤@¬P´Á(5) = "¬P´Á¤­"

  10.         ¤@¬P´Á(6) = "¬P´Á¤»"
  11.   MessageBox.Show(¤@¬P´Á(5))
  12.     End Sub
  13. End Class
½Æ»s¥N½X
·íµM§A¤]¥i¥H¤@¶}©l´Nµ¹°_©l­È¦p¦P¤@¥H¤U½d¨Ò
°}¦C¤ºªº¯Á¤Þ­È¤£¥Îµ¹,ª½±µ¥Ñ«á­±°_©l­Èªº¼Æ¶q¨Ó¨M©w
  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.         MessageBox.Show(¤@¬P´Á(5))
  5.     End Sub
  6. End Class
½Æ»s¥N½X
±z¤]¥i¥H§Q¥Î°j°é¨Ó°µ¤@¦¸¦s¨ú¦p¤U
  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
¥H¤WºÙ¬°¤@ºû°}¦C,¤]´N¬O¥u¦³¤@­Ó¯Á¤Þ­È¦b°}¦C¤¤
§Ú­Ì¤]¥i¥H«Å§i¤@­Ó¤Gºû°}¦C,¨º´N¬O   
dim Cell(RowIndex,ColumnIndex) as integer
¬JµM³o¸Ì¦³¤@°ï Excel ª±®a,¨º¥ÎexcelÀx¦s®æ¨Ó¸Ñ¦¡¬O³Ì§Öªº,¤@­ÓÀx¦s®æªº¦ì¸m¦b²Ä´X¦æ,²Ä´X¦C³o¼Ë´N°÷²M·¡¤F§a
¦ýexcel¦n¹³¬O±q²Ä¤@¦æ¶}©l,¦Ó°}¦C¬O±q²Ä0¦æ¶}©l³o¬O­nª`·Nªº¦a¤è
¨º¤Tºû°}¦C©O,¨º´N¬O
dim cell(workSheetIndex,rowindex,columnindex) as integer
¤]´N¬O¥h§ä²Ä´X±i¤u§@ªí¤¤ªº¦æ¦C­È
¨º¥|ºûªº·N¸q©O
dim cell(FileIndex,worksheetindex,rowindex,columndex) as integer
¤]´N¬O¦b¦P¤@­Ó¸ê®Æ§¨¤º,¦pªGÀɦW¬O©R¦¨1,2,3ªº¬y¤ô¸¹,¨º´Ncell(1,2,3,4)ªº·N¸q´N¬O ²Ä¤@­ÓÀɮפ¤ªº²Ä¤G±i¤u§@ªí¤¤ªº²Ä¤T¦C²Ä¥|¦æªº­È
¨º¤Gºû°}¦C­n¦p¦ó¦s¨ú
¥H¤@¤U¬O¤@­Ó¨Ò¤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 A(,) As Integer = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, _
  4.                                {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, _
  5.                                {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}}
  6.         For i As Integer = 0 To A.GetUpperBound(0)
  7.             For j As Integer = 0 To A.GetUpperBound(1)
  8.                 MessageBox.Show(A(i, j))
  9.             Next j
  10.         Next i

  11.     End Sub
  12. End Class
½Æ»s¥N½X
¤W­±µ{¦¡½Xªº·N«ä¬O»¡,§Ú«Å§i¤F¤@­Ó¤Gºû°}¦C,³o­Ó¤Gºû°}¦C¬O¥Ñ3­Ó¤@ºû°}¦C©Ò²Õ¦¨
¨ä¤¤¨C­Ó¤@ºû°}¦C³£¦³10­Ó¼Æ
getupperbound(0)¦^¶Ça°}¦C¤¤²Ä¤@­Ó¯Á¤Þ­È
getupperbound(1)¦^¶Ça°}¦C¤¤²Ä¤G­Ó¯Á¤Þ­È

¦³®É­Ô,§Ú­Ì¥²»Ý­n§ïÅÜ°}¦Cªº¤j¤p, ¦]¦¹,§Ú­Ì¦³¤@ºØ»yªk¥s redim ¥i¥HÅÜÅÜ°}¦Cªº¤j¤p
¥H¤U¬°½d¨Ò
  1. Public Class Form1
  2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         Dim ¥iÅܤj¤pªº°}¦C() As Integer = {1, 2, 3, 4, 5}
  4.         ReDim ¥iÅܤj¤pªº°}¦C(10)
  5.         For Each ¤¸¯À In ¥iÅܤj¤pªº°}¦C
  6.             MessageBox.Show(¤¸¯À.ToString())
  7.         Next
  8.     End Sub
  9. End Class
½Æ»s¥N½X
§Ú­Ì¥i¥H¬Ý¨ì,§ïÅܫ᪺°}¦C¨C­Ó­È³£¬O0,¦ý§Ú­Ì¦³®É­Ô·Q­nªº¬O«O¯d­ì¥ýªº­È,¨º­n¦p¦ó°µ,§Ú­Ì¥i¥H¥[¤W Preserve
¦p¤U¬°½d¨Ò
  1. Public Class Form1

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

  3.         Dim ¥iÅܤj¤pªº°}¦C() As Integer = {1, 2, 3, 4, 5}

  4.         ReDim Preserve ¥iÅܤj¤pªº°}¦C(10)

  5.         For Each ¤¸¯À In ¥iÅܤj¤pªº°}¦C

  6.             MessageBox.Show(¤¸¯À.ToString())
  7.         Next
  8.     End Sub
  9. End Class
½Æ»s¥N½X

TOP

§b§b §A»Å²¦¤F ¯u¬O°ª¤â ¤p§Ì¹ï§Aªº´º¥õ¦³¦p·Ê·Ê¦¿¤ôºø©µ¤£µ´¤S¦³¦p¶Àªe¥ÆÀݤ@µo¤£¥i¦¬¬B
¥¿©Ò¿× Á|ÀY±æ©ú¤ë §CÀY«ä¬G¶m ¦n¸Ö ¦n¸Ö
­Ó¤Hñ¦W@

TOP

        ÀR«ä¦Û¦b : ¨C¤ÑµL©Ò¨Æ¨Æ¡A¬O¤H¥Íªº®ø¶OªÌ¡A¿n·¥¡B¦³¥Î¤~¬O¤H¥Íªº³Ð³yªÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD