- ©«¤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 ·s¤â±Ð¾Ç ¤§ µ{§Ç»P¨ç¼Æ
¥»©«³Ì«á¥Ñ §b§b ©ó 2010-5-29 18:09 ½s¿è
µ{§Ç»P¨ç¼Æ
- µ{§Ç
¤@¯ë¦Ó¨¥,¦pªG§Ú̱`°µ¬Y¤@¥ó¨Æ,¨º³o¥ó¨Æ±¡ªºµ{¦¡½X´N¥i¥H¼g¦b¤@Óµ{§Ç¤¤,¨C·í§ÚÌn°µ³o¥ó¨Æ®É´N¥i¥H©I¥s³oÓµ{§Ç
µ{§Ç¤@¯ë¦Ó¨¥·|¦³¤U¦Cªº»yªk- Sub µ{§Ç¦WºÙ()
- '§An°µªº¨Æ
- End
½Æ»s¥N½X ¥H¤Uµ{¦¡½X¥i¥H¨D¥X1+2+3....+10- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ¨DÁ`©M()
- End Sub
- Sub ¨DÁ`©M()
- Dim Á`©M As Integer = 0
- For i As Integer = 0 To 10
- Á`©M = Á`©M + i
- Next
- MessageBox.Show(Á`©M.tostring)
- End Sub
- End Class
½Æ»s¥N½X §ÚÌ©I¥sµ{§Ç®É¥un¦bµ{¦¡½X¤WÁä¤Jµ{§Ç¦WºÙ´N¥i¥H¤F,³o¼Ëªº¸Ü,¦pªG§ÚÌ·Qn1¨ì10ªº¥[Á`,´N¥i¥H¤@ª½§Q¥Î¨DÁ`©M³oÓµ{§Ç¤F,³o¼Ë¤£¬O«Ü¤è«K¶Ü
¦ý´N¦³¤H·Q¨ì¤F,§Ú³o¼Ë¥u¯à¨D1¥[¨ì10,¨º»ò§Ú·Q¤@¥[¨ì¥ô·N¼Æ©O©ÎªÌ¬O³sÄòªº¾ã¼ÆÁ`©M©O¨ºn«ç»ò¿ì,·íµM,³o¸Ì´N¸Ì¨Ñ¤F©w¸q³oºØµ{§Çªº»yªk
Sub µ{§Ç¦Wµ{(byval ÅܼÆ1 as «¬ºA ,byval ÅܼÆ2 as «¬ºA,.........,byval ÅܼÆn as «¬ºA )
End sub
¦]¦¹§ÚÌ´N¥i¥H¦b©I¥sµ{§Ç®É§Q¥Î¶Ç¤JÅܼƪº¤èªkÅýµ{§Ç¤º³¡¥i¥H§Q¥Î³oÓÅܼƨӰµ¨Æ¥H¤U¬°½d¨Ò- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ¨DÁ`©M(-10, 100)
- End Sub
- Sub ¨DÁ`©M(ByVal °_©lÈ As Integer, ByVal ²×¤îÈ As Integer)
- Dim Á`©M As Integer = 0
- For i As Integer = °_©lÈ To ²×¤îÈ
- Á`©M = Á`©M + i
- Next
- MessageBox.Show(Á`©M.ToString)
- End Sub
- End Class
½Æ»s¥N½X ¨Æ¹ê¤W¶Ç¤JÅܼƤÀ¬°¤GºØ,¤@ºØ¬O¶ÇÈ,¥t¤@ºØ¬O¶Ç§},§Ṳ́W±¥Îªº¬O¶ÇÈ,°_©lȬO-10,²×¤îȬO100
³o¤GºØ¦³¤°»ò¤£¦P©O,¥H¤U¬°µ{¦¡½X- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim °_©lÈ As Integer = -10
- Dim ²×¤îÈ As Integer = 100
- Dim Á`©M As Long = 0
- ¨DÁ`©M(°_©lÈ, ²×¤îÈ, Á`©M)
- MessageBox.Show("°_©lÈ =" & °_©lÈ & vbCrLf & "²×¤îÈ = " & ²×¤îÈ & vbCrLf & "Á`©M=" & Á`©M.ToString)
- End Sub
- Sub ¨DÁ`©M(ByVal °_©lÈ As Integer, ByVal ²×¤îÈ As Integer, ByRef Á`©M As Long)
- For i As Integer = °_©lÈ To ²×¤îÈ
- Á`©M = Á`©M + i
- Next
- °_©lÈ = 1000
- ²×¤îÈ = 1000
- MessageBox.Show("°_©lÈ =" & °_©lÈ & vbCrLf & "²×¤îÈ = " & ²×¤îÈ & vbCrLf & "Á`©M=" & Á`©M.ToString)
- End Sub
- End Class
½Æ»s¥N½X §Ú̥ѵ²ªG«Ü§Öªº´N¥i¥H¤F¸Ñ,Á`©M³oÓÅܼƧÚ̬O¶Ç§}ªº,¤]´N¬O»¡,¦b¥D«ö¶sµ{§Ç¤¤ªºÁ`©MÅܼƨä¹ê¬O©Mµ{§Ç ¨DÁ`©M ¤¤ªºÁ`©MÅܼƬO¦@¥Î¦P¤@¦ì§}
¦]¦¹·í§ÚÌקï¤F¨DÁ`©Mµ{§Ç¤¤ªºÁ`©MÅܼƨº´N·|³s¦P«ö¶sµ{§Ç¤ºªºÁ`©MÅܼƤ@°_קï,¤]´N¬O¶Ç§}(byref)
µM¦Ó,¶ÇÈ(byval)¬O¤£¤@¼Ëªº,§Ú̦b¨DÁ`©Mµ{§Ç¤¤×§ï¤F°_©lÈ©M²×¤îȪºÈ,µ²ªG«ö¶s¤ºªº°_©lÈ©M²×¤îȪºµ²ªG¨ÌµM¤£ÅÜ ,¤ñ¸û²³æªº»¡ªk¬O
¦pªG§A·Qn§A¶Ç¤Jµ{§Ç¤¤ªºÅܼÆȦbµ{§Çµ²§ô«á·|§ïÅܨ䵲ªG¨º´NÀ³¸Ó¶Ç§}(byref),¦pªG¤£·Q,¨º´NÀ³¸Ó¶ÇÈ(byval),¥t¥~,¦pªG§A¶Çªº¬O°Ñ¦Ò«¬§O,¨º¤£½×¬O¶ÇȩάO¶Ç§}³£¤@¼Ë¬O°Ñ¦Ò¨ì¦ì§}- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim °}¦C() As Integer = {1, 2, 3, 4, 5}
- קï°}¦CÈ(°}¦C)
- For Each ¤¸¯À As Integer In °}¦C
- MessageBox.Show(¤¸¯À.ToString)
- Next
- End Sub
- Sub קï°}¦CÈ(ByVal קï«á°}¦C() As Integer)
- For i As Integer = 0 To קï«á°}¦C.GetUpperBound(0)
- קï«á°}¦C(i) = i + 10
- Next i
- End Sub
- End Class
½Æ»s¥N½X ¥Ñ¥H¤Wªºµ²ªG¥iª¾,´Nºâ¬O¶ÇÈ,¹ï©ó°}¦C¦Ó¨¥,¤@¼Ë·|קï°}¦C¤¤ªºÈ,¥u¦]¬°°}¦C¬O°Ñ¦Ò«¬§O
- ¨ç¼Æ
µ{§Ç¹ê»Ú¤W¨Ã¤£¯à¶Ç¦^È,§Ú̦³®ÉÔ¦bµ{§Ç°õ¦æ§¹®É·Qn¦³¤@¨ÇȦ^¶Ç,³o®ÉÔ´N»Ýn¨ç¼Æ
©w¸q¨ç¼Æªº»yªk¦p¤U
Function ¨ç¼Æ¦WºÙ(ByVal ¤Þ¼Æ¤@ As «¬ºA, ByVal ¤Þ¼Æ¤G As «¬ºA) As «¬ºA
Return ÅܼÆ
End Function
©Mµ{§Ç¤£¦Pªº¬O,¨ç¼Æ¤@©wn¶Ç¦^È,¸Ó¦^Ȫº«¬ºA¤@©wn©M¨ç¼Æ¥»¨©w¸qªº«¬ºA¬Û¦P
§Ú̧ï¼g¤W±ªº¨Ò¤l¦p¤U- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- MessageBox.Show(¨DÁ`©M(-10, 100).ToString)
- End Sub
- Function ¨DÁ`©M(ByVal °_©lÈ As Integer, ByVal ²×¤îÈ As Integer) As Integer
- Dim Á`©M As Integer = 0
- For i As Integer = °_©lÈ To ²×¤îÈ
- Á`©M = Á`©M + i
- Next
- Return Á`©M
- End Function
- End Class
½Æ»s¥N½X «Ü²M·¡ªº§ÚÌ¥i¥H¬Ý¨ì¨ç¼Æ¥»¨´N¥i¥H¦³È
¥t¥~,¨ç¼Æ¥»¨¥ç¦^¶Ç°}¦C¥H¤U¬°¨Ò- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- For Each ¤¸¯À In ¦^¶Ç¦hÓÈ()
- MessageBox.Show(¤¸¯À.ToString)
- Next
- End Sub
- Function ¦^¶Ç¦hÓÈ() As Integer()
- Dim ¦^¶Ç°}¦C() As Integer = {1, 2, 3, 4, 5}
- Return ¦^¶Ç°}¦C
- End Function
- End Class
½Æ»s¥N½X
µ{§Ç©M¨ç¼Æ³£¥i¥H¦³¦h¸ü,©Ò¿×ªº¦h¸ü´N¬O¦P¼Ëªº ¨ç¼Æ/µ{§Ç ¦WºÙ ,¦ý¤º³¡©w¸q¤£¦P
,·|¦³³oºØªº¤èªk¥Dn¬O¤è«K§ÚÌ¥un©w¤@Ó ¨ç¼Æ/µ{§Ç ¦WºÙ ´N¥i¥H°µ¥X¤£¦Pªº¤èªk
¦h¸üªº»yªk¬°¥un¦b ¨ç¼Æ/µ{§Ç ¤§«e¥[¤@ÓOverloads ´N¥i¥H- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim À\¨ã As String = "¸_¤l"
- ¶¼¹(À\¨ã)
- ¶¼¹()
- End Sub
- Sub ¶¼¹(ByVal À\¨ã As String)
- MessageBox.Show("¥xÆW¤H¥Î" & À\¨ã & "¦Y¶º")
- End Sub
- Overloads Sub ¶¼¹()
- MessageBox.Show("¦L«×¤H¥Î¥k¤â±N¶º®º¦¨¤@¹Î¨Ó¦Y")
- End Sub
- End Class
½Æ»s¥N½X |
|