vb.net關(guān)鍵字 vb常用關(guān)鍵字

VB.NET關(guān)鍵字的問題

是關(guān)鍵字。比如:SUB代表一個函數(shù)的開始,END SUB代表函數(shù)結(jié)束,函數(shù)主體語句就必須寫在這兩個關(guān)鍵字之間。CLASS類關(guān)鍵字,PRIVATE私有關(guān)鍵字,PUBLIC公用關(guān)鍵字,IF.....END IF是判斷關(guān)鍵字,等等。建議找本基礎(chǔ)書看一看。

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

VB.NET關(guān)鍵字上色/高亮問題。

Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

Dim pos = RichTextBox1.SelectionStart

Dim i As String = Regex.Matches(RichTextBox1.Text, "\bDim\b").ToString

RichTextBox1.SelectAll

RichTextBox1.SelectionColor = Color.Black

If Regex.IsMatch(RichTextBox1.Text, "\bDim\b") = True Then

For Each mat As Match In Regex.Matches(RichTextBox1.Text, "\bDim\b")

RichTextBox1.SelectionStart = mat.Index

RichTextBox1.SelectionLength = mat.Length

RichTextBox1.SelectionColor = Color.YellowGreen

Next

End If

RichTextBox1.SelectionStart = pos

RichTextBox1.SelectionLength = 0

End Sub

我做了一個更詳細的正則:

Friend Keys As String =

"\b(#Const|#If|Then|#Else|#Region|Delegate|Namespace|Class|End|Firend|Partial|Module|Interface|Enum|Shared|Overrides|Overloads|Structure|Let|Const|Dim|As|Private|Public|New|Static|Option|Private|Module|IsArray|IsDate|IsEmpty|IsError|IsMissing|IsNull|IsNumeric|IsObject|TypeName|VarType|Me|Option|Explicit|Mod|Like|Is|Not|And|Or|Xor|Eqv|Imp|Clear|Error|Raise|Error|Err|CVErr|On|Error|Resume|IsError|Collection|Add|Remove|Item|DDB|SLN|SYD|FV|Rate|IRR|MIRR|NPer|IPmt|Pmt|PPmt|NPV|PV|Do|Loop|For|Next|For|Each|Next|While|Wend|With|Choose|If|Then|Else|Select|Case|Switch|Call|Function|Property|Get|Property|Let|Property|Set|Sub|Date|Now|Time|DateAdd|DateDiff|DatePart|DateSerial|DateValue|TimeSerial|TimeValue|Date|Time|Timer|CBool|CByte|CCur|CDate|CDbl|CDec|CInt|CLng|CSng|CStr|CVar|CVErr|Fix|Int|Boolean|Byte|Currency|Date|Double|Integer|Long|Object|Single|String|Object|Atn|Cos|Sin|Tan|Exp|Log|Sqr|Randomize|Rnd|Abs|Sgn|Fix|Int|IsArray|Array|Option|Base|Dim|Private|Public|ReDim|Static|LBound|UBound|Erase|ReDim|DeleteSetting|GetSetting|GetAllSettings|SaveSetting|Chr|Format|LCase|UCase|DateSerial|DateValue|Hex|Oct|Format|Str|CBool|CByte|CCur|CDate|CDbl|CDec|CInt|CLng|CSng|CStr|CVar|CVErr|Fix|Int|Day|Month|Weekday|Year|Hour|Minute|Second|Asc|Val|TimeSerial|TimeValue|StrComp|StrConv|Format|LCase|UCase|Space|String|Len|Format|LSet|RSet|InStr|Left|LTrim|Mid|Right|RTrim|Trim|Option|Compare|Asc|Chr|AppActivate|Shell|SendKeys|Beep|Command)\b"

vb.net關(guān)鍵字搜索文件

窗體上添加一個文本框,一個列表框,一個按鈕:

代碼如下:

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

Dim MyDir As String = "C:\123"

Dim MyFilter As String = "*" TextBox1.Text "*"

ListBox1.Items.Clear()

For Each MyFile As String In System.IO.Directory.GetFiles(MyDir, MyFilter)

ListBox1.Items.Add(MyFile)

Next

End Sub

vb.net 中的關(guān)鍵字有 print嗎?

有的,功能:

將為顯示而格式化的數(shù)據(jù)寫入順序文件。

你使用下面這段例子,看看結(jié)果:

FileOpen(1, "c:\實驗.txt", OpenMode.Output) ' Open file for output.

Print(1, "This is a test.") ' Print text to file.

PrintLine(1) ' Print blank line to file.

PrintLine(1, "Zone 1", TAB(), "Zone 2") ' Print in two print zones.

PrintLine(1, "Hello", "World") ' Separate strings with a tab.

PrintLine(1, SPC(5), "5 leading spaces ") ' Print five leading spaces.

PrintLine(1, TAB(10), "Hello") ' Print word at column 10.

vb.net聲明對象用new關(guān)鍵字與不用關(guān)鍵字new的區(qū)別

顧名思義,new就是給變量賦值一個新的對象

dim不加new就是說變量是XX類型的,但它不是一個真正的XX對象。如果給這個變量賦值的話,實際上就是把某一對象的指針存到變量里,它依舊不是一個對象

一個普通的類,里面有一些數(shù)據(jù),你要弄一個對象的話,需要初始化所有類中的數(shù)據(jù)并調(diào)用構(gòu)造函數(shù)。這時候我們就用new了。如果你不用new,然后直接使用的話,會引發(fā)null異常

當(dāng)然上面的討論不包括Integer、String、Long這樣的數(shù)值類型,這些不能用new

網(wǎng)站欄目:vb.net關(guān)鍵字 vb常用關(guān)鍵字
分享路徑:http://muchs.cn/article44/hjcpee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、做網(wǎng)站、網(wǎng)站策劃、建站公司、定制開發(fā)

廣告

聲明:本網(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)

營銷型網(wǎng)站建設(shè)