你只是定義了一個對象,類而已

創(chuàng)新互聯(lián)是一家專業(yè)提供興安盟企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站建設(shè)、網(wǎng)站制作、成都h5網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為興安盟眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進行中。
首先要給對象設(shè)置變量,這個還不是數(shù)組
Public class As Single的class 應(yīng)該是關(guān)鍵字請換一個名字
Dim KidsX(1 to 100) as kids
KidsX(1).classx=1
KidsX(1).grade=1
KidsX(1).name=”張某"
KidsX(2).classx=1
KidsX(2).grade=2
KidsX(2).name=”王某"
……
Dim a(3, 3, 3)
Dim b(3, 3), c(3, 3), d(3, 3)
Private Sub aaa()
' 對數(shù)組a(3,3,3)賦值
For i = 1 To 3
For j = 1 To 3
b(i, j) = a(1, i, j)
Next
Next
For i = 1 To 3
For j = 1 To 3
c(i, j) = a(2, i, j)
Next
Next
For i = 1 To 3
For j = 1 To 3
d(i, j) = a(3, i, j)
Next
Next
End Sub
public function createstringarr() as string()
return new string(){"d1","d2","d3","d4"}
end function
vb.net已經(jīng)去掉了控件數(shù)組這個類,不過有個代替該方式的一個屬性:Tag,你可以把這些關(guān)聯(lián)的Tag屬性設(shè)置為同一標(biāo)記,如:a。然后遍歷所有的checkbox并且tag為a的則選定:Protected Sub chkAll_Click() For Each ctl As Control In Me.Controls ''如果checkbox在一個容器里,比如groupbox,那可以用groupbox.controls
If ctl.GetType().Name.ToLower() = "checkbox" Then
CType(ctl, CheckBox).Checked = CheckBox3.Checked
End If
NextEnd Sub
每個 Visual Basic 應(yīng)用程序均必須包含一個稱為VB.NET Main過程。該過程為應(yīng)用程序的起始點并為應(yīng)用程序提供總體控制。.NET Framework 在已加載應(yīng)用程序并準(zhǔn)備將控制傳遞給它時,將調(diào)用 Main 過程。除非您要創(chuàng)建 Windows 窗體應(yīng)用程序,否則就必須為自運行的應(yīng)用程序編寫 Main 過程。
Main 中包含首先運行的代碼。在 Main 中,可以確定在程序啟動時首先加載的窗體,確定系統(tǒng)上是否已在運行您的應(yīng)用程序副本,為應(yīng)用程序建立一組變量,或者打開應(yīng)用程序需要的數(shù)據(jù)庫。
VB.NET Main過程的要求
獨立運行的文件(擴展名通常為 .exe)必須包含 Main 過程。庫(例如,擴展名為 .dll)不獨立運行,因而不需要 Main 過程。可以創(chuàng)建的不同類型的項目的要求如下:
控制臺應(yīng)用程序可以獨立運行,而且您必須提供至少一個 Main 過程。
Windows 窗體應(yīng)用程序可以獨立運行。但是,Visual Basic 編譯器會在此類應(yīng)用程序中自動生成一個 Main 過程,因而您不需要編寫此過程。
類庫不需要 Main 過程。這些類庫包括 Windows 控件庫和 Web 控件庫。作為類庫部署 Web 應(yīng)用程序。
聲明VB.NET Main過程
有四種方法可以聲明 Main 過程。它可以使用參數(shù)或不使用參數(shù),可以返回值或不返回值。
注意
如果在類中聲明 Main 過程,則必須使用 Shared 關(guān)鍵字。在模塊中,Main 不必是 Shared。
最簡單的方法是聲明一個不使用參數(shù)或不返回值的 Sub 過程。
Module mainModule
Sub Main()
MsgBox("The Main procedure
is starting the application.")
' Insert call to appropriate
starting place in your code.
MsgBox("The application
is terminating.")
End Sub
End ModuleMain
還可以返回一個 Integer 值,操作系統(tǒng)將其作為程序的退出代碼。其他程序可以通過檢查 Windows ERRORLEVEL 值來測試該代碼。若要返回退出代碼,必須將VB.NET Main過程聲明為 Function 過程而不是 Sub 過程。
Module mainModule
Function Main() As Integer
MsgBox("The Main procedure
is starting the application.")
Dim returnValue As Integer = 0
' Insert call to appropriate
starting place in your code.
' On return, assign appropriate
value to returnValue.
' 0 usually means successful
completion.
MsgBox("The application is
terminating with error level " _
CStr(returnValue) ".")
Return returnValue
End Function
End ModuleMain
還可以采用一個 String 數(shù)組作為參數(shù)。數(shù)組中的每個字符串均包含一個用于調(diào)用程序的命令行參數(shù)。您可以根據(jù)它們的值采取不同的操作。
Module mainModule
Function Main(ByVal cmdArgs()
As String) As Integer
MsgBox("The Main procedure is
starting the application.")
Dim returnValue As Integer = 0
' See if there are any arguments.
If cmdArgs.Length 0 Then
For argNum As Integer = 0 To
UBound(cmdArgs, 1)
' Insert code to examine cmdArgs
(argNum) and take
' appropriate action based on its value.
Next argNum
End If
' Insert call to appropriate starting
place in your code.
' On return, assign appropriate
value to returnValue.
' 0 usually means successful completion.
MsgBox("The application is
terminating with error level " _
CStr(returnValue) ".")
Return returnValue
End Function
End Module
可以聲明VB.NET Main過程來檢查命令行參數(shù)而不返回退出代碼,如下所示。
Module mainModule
Sub Main(ByVal cmdArgs() As String)
MsgBox("The Main procedure is
starting the application.")
Dim returnValue As Integer = 0
' See if there are any arguments.
If cmdArgs.Length 0 Then
For argNum As Integer = 0 To
UBound(cmdArgs, 1)
' Insert code to examine cmdArgs
(argNum) and take
' appropriate action based on its value.
Next argNum
End If
' Insert call to appropriate
starting place in your code.
MsgBox("The application is
terminating."
End Sub
End Module
給你一個簡單的示例:
Option?Explicit
Private?Function?GetRndInt()?As?Integer()
'?返回一個?Integer類型的數(shù)組
Dim?i?As?Long,?aTemp()?As?Integer
Randomize
ReDim?aTemp(15)
For?i?=?0?To?15
aTemp(i)?=?Rnd()?*?500
Next
GetRndInt?=?aTemp
End?Function
Private?Sub?Command1_Click()
Dim?aTemp()?As?Integer
Dim?i?As?Long
Me.Cls
aTemp?=?GetRndInt
Print?"隨機產(chǎn)生的數(shù)據(jù)為:"
For?i?=?0?To?UBound(aTemp)
Print?i?+?1,?aTemp(i)
Next
End?Sub
運行效果:
當(dāng)前題目:關(guān)于vb.net數(shù)組退出的信息
文章出自:http://chinadenli.net/article4/dodhdie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、網(wǎng)站改版、小程序開發(fā)、企業(yè)網(wǎng)站制作、移動網(wǎng)站建設(shè)、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)