欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

vb.net入口主函數(shù),主函數(shù)是c程序的入口

vb.net 窗體程序的入口在哪

方法如下:

大名網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),大名網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為大名成百上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請找那個售后服務(wù)好的大名做網(wǎng)站的公司定做!

1、打開例1.1創(chuàng)建的工程。

2、選擇窗體Form1并雙擊該窗體,出現(xiàn)窗體的調(diào)事件的過程代碼體。

3、在窗體調(diào)用的過程代碼體中編制如下過程代碼:

Private Sub Form_Load()

Form1.Width = 4860

Form1.Height = 2520

End Sub

4、設(shè)置窗體Form1的SartUpPosition屬性為2-屏幕中心,這樣運(yùn)行窗體可以發(fā)現(xiàn),屏幕的大小與例1.6中通過屬性設(shè)置的大小是一致的。

詳細(xì)闡述 vb.net 中main

每個 Visual Basic 應(yīng)用程序均必須包含一個稱為VB.NET Main過程。該過程為應(yīng)用程序的起始點(diǎn)并為應(yīng)用程序提供總體控制。.NET Framework 在已加載應(yīng)用程序并準(zhǔn)備將控制傳遞給它時,將調(diào)用 Main 過程。除非您要創(chuàng)建 Windows 窗體應(yīng)用程序,否則就必須為自運(yùn)行的應(yīng)用程序編寫 Main 過程。

Main 中包含首先運(yùn)行的代碼。在 Main 中,可以確定在程序啟動時首先加載的窗體,確定系統(tǒng)上是否已在運(yùn)行您的應(yīng)用程序副本,為應(yīng)用程序建立一組變量,或者打開應(yīng)用程序需要的數(shù)據(jù)庫。

VB.NET Main過程的要求

獨(dú)立運(yùn)行的文件(擴(kuò)展名通常為 .exe)必須包含 Main 過程。庫(例如,擴(kuò)展名為 .dll)不獨(dú)立運(yùn)行,因而不需要 Main 過程。可以創(chuàng)建的不同類型的項(xiàng)目的要求如下:

控制臺應(yīng)用程序可以獨(dú)立運(yùn)行,而且您必須提供至少一個 Main 過程。

Windows 窗體應(yīng)用程序可以獨(dú)立運(yùn)行。但是,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

VB.NET string$函數(shù)

VB6的String()函數(shù),在VB.NET中,改用 StrDup()函數(shù),使用格式與VB6的String()函數(shù)類似:

例如:

VB6中,String(5,"*") ,是產(chǎn)生5個星號字符,"*****"

VB.Net中,改用 StrDup(5,"*") ,也是產(chǎn)生5個星號字符,"*****"

VB.net窗體程序如何讓cmd調(diào)用?

VB.NET 里面會有一個main方法表示函數(shù)的入口

main方法的參數(shù)就是命令行傳給它的

shutdown.exe能直接調(diào)用是因?yàn)槟愕沫h(huán)境變量有C盤的windows目錄

你只要在你程序的輸出目錄(一般為bin)里面打開命令行輸入程序名稱.exe就可以直接執(zhí)行你的窗體

如果你要調(diào)試輸入命令的效果,你打開你項(xiàng)目的屬性,找到調(diào)試?yán)锩娴拿钚袇?shù),在里面輸入測試參數(shù)就能在你main函數(shù)里面看到結(jié)果了

那如果你想打開任何命令行都可以執(zhí)行你的窗體程序,那你把你程序的安裝目錄設(shè)置為環(huán)境變量,這樣就可以直接執(zhí)行這個命令了

VB.Net Sub Main 的問題

看你的意思,你是不是想問怎么在VB.NET中獲取命令行參數(shù)?如果是這樣,很簡單,在Vb.NET中,利用System.Environment.GetCommandLineArgs函數(shù)返回一組系統(tǒng)傳送的啟動參數(shù)。

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

Dim myArg() As String, i As Integer

myArg = System.Environment.GetCommandLineArgs

If myArg.Length 0 Then

For i = 1 To UBound(myArg)

MsgBox(myArg(i).ToString)

Next

End If

End Sub

假設(shè)你的程序編譯為A.EXE,運(yùn)行時用 A.EXE /a /s /pt 帶參數(shù)運(yùn)行,則用上述代碼,可分別顯示/a /s /pt

分享名稱:vb.net入口主函數(shù),主函數(shù)是c程序的入口
文章源于:http://chinadenli.net/article46/phiohg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化網(wǎng)站收錄網(wǎng)站策劃品牌網(wǎng)站建設(shè)網(wǎng)站制作虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站