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

vb.net中修改字符串 vb 替換字符串

VB.NET中如何擴(kuò)充字符串進(jìn)行固定寬度顯示

在VB NET中 當(dāng)你需要在控制臺顯示數(shù)據(jù)或準(zhǔn)備好打印數(shù)據(jù)時(shí) 可能需要調(diào)整列寬以顯示固定長度的數(shù)據(jù) 本文介紹了使用String對象的PadLeft方法和PadRight方法擴(kuò)充字符串以進(jìn)行固定寬度顯示

創(chuàng)新互聯(lián)建站專注于洛江網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供洛江營銷型網(wǎng)站建設(shè),洛江網(wǎng)站制作、洛江網(wǎng)頁設(shè)計(jì)、洛江網(wǎng)站官網(wǎng)定制、小程序制作服務(wù),打造洛江網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供洛江網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

PadLeft和PadRight方法

PadLeft和PadRight是字符串類的兩個(gè)方法 可以分別使用它們在字符串的左邊和右邊填充空格 這兩個(gè)方法多接受一個(gè)代表總長度的整型數(shù) 添加的空格數(shù)等于填充總長度減去字符串的當(dāng)前長度

注意 在完成將字符串格式化為固定寬度顯示的工作時(shí) 應(yīng)該使用固定寬度的字體 例如Courier等 因?yàn)楣潭▽挾鹊淖址加邢嗤膶挾?否則 填充將會無效

程序員經(jīng)常使用的另一個(gè)替代方法是使用tab字符來獲得近似固定寬度顯示格式 使用tabs的一個(gè)問題是 當(dāng)某行長度比能夠顯示的長度長時(shí) 將會對tab進(jìn)行擴(kuò)展 這將導(dǎo)致各行不能很好對齊

列表A中 我們?yōu)榇蠹医榻B了如何使用PadLeft和PadRight方法顯示字符串 (為了運(yùn)行該例子 我們添加了一個(gè)下拉列表ListBox 并將它的字體設(shè)置為固定寬度的字體)圖 顯示了運(yùn)行列表A中的代碼后的結(jié)果

在本例中 我們定義了一個(gè)整型變量i和兩個(gè)字符串?dāng)?shù)組 strArrSeasons和strArrWeather 每個(gè)數(shù)組賦初值為預(yù)定義好的值 然后 我們將每個(gè)數(shù)組傳遞給函數(shù)PadArray 并指定在字符串的左側(cè)擴(kuò)充

列表A

lishixinzhi/Article/program/net/201311/11703

vb.net字符串 替換

x="a[11dsfsf]b"

b=x.lastindexof("]")

a=x.indexof("[")

x=x.substring(0,a) "0" x.substring(b)

vb.net字符串的操作應(yīng)用

字符串的操作應(yīng)用

[vb]

Module Module

Sub Main()

定義 個(gè)字符串變量

Dim str str str As String

給str str 付初值

str = Hello : str = World

Console WriteLine( 方法Concat )

連接一個(gè)或多個(gè)字符串

Console WriteLine( str ={ } str ={ } String Concat(str str )={ } str str String Concat(str str ))

判斷字符串中是否具有相同的值返回類型為布爾型

Console WriteLine( 方法Equals )

Console WriteLine( str ={ } str ={ } String Equals(str )={ } str str str Equals(str ))

在字符串中指定索引位置插入指定的字符串

Console WriteLine( 方法Insert )

str = : str = aaa

Console WriteLine( str ={ } str ={ } str Insert( str )={ } str str str Insert( str ))

左右對齊字符串中的字符

Console WriteLine( 方法PadLeft/PadRight )

str = World : str = 世界

Console WriteLine( str ={ } str )

Console WriteLine( str PadLeft( * )={ } str PadRight( * )={ } str PadLeft( * ) str PadRight( * ))

Console WriteLine( str ={ } str )

Console WriteLine( str PadLeft( * )={ } str PadRight( * )={ } str PadLeft( * ) str PadRight( * ))

找出指定字符串或字符轉(zhuǎn)在此字符串中的第一個(gè) 最后一個(gè)匹配項(xiàng)的索引位置

Console WriteLine( 方法IndexOf/LastIndexOf )

str = Visual Basic NET ASP NET C# NET

Console WriteLine( str ={ } str )

Console WriteLine( str IndexOf( NET )={ } str LastIndexOf( NET )={ } str IndexOf( NET ) str LastIndexOf( NET ))

將字符串中的字符復(fù)制到字符串?dāng)?shù)組

Console WriteLine( 方法ToCharArray )

str = str ToCharArray(str IndexOf( NET ) )

Console WriteLine( str ={ } str )

Console WriteLine( str ToCharArray(str IndexOf( NET ) )={ } str )

在指定字符串?dāng)?shù)組的每個(gè)元素之間串聯(lián)指定的分隔符 產(chǎn)生單個(gè)串聯(lián)的字符串

Console WriteLine( 方法Join )

Dim myArray( ) As String

myArray( ) = I : myArray( ) = am : myArray( ) = a : myArray( ) = student

For i As Integer = To

Console Write( myArrat({ })={ } i myArray(i))

Next

Console WriteLine()

Console WriteLine( String Join( * myArray)={ } String Join( * myArray))

此字符串中刪除指定個(gè)數(shù)字符

Console WriteLine( 方法Remove )

str =

Console WriteLine( str ={ } str Remove( )={ } str str Remove( ))

將此字符串指定字符串字符的所有匹配項(xiàng)代替為其他指定字符串

Console WriteLine( 方法Replace )

str =

str = abc

Console WriteLine( str ={ } str ={ } str ={ } str Replace(str str )={ } str str str str Replace(str str ))

從此字符串檢索字符串

Console WriteLine( 方法SubString )

Console WriteLine( str ={ } str Substring( )={ } str str Substring( ))

Console ReadLine()

End Sub

lishixinzhi/Article/program/net/201311/13956

vb.Net對文件指定字符串的修改

文本框 TextBox1

上一條 Button1

下一條 Button2

修改 Button3

Imports?System.IO

Public?Class?Form1

Dim?currIndex?As?Integer?=?0

Dim?s2?As?List(Of?String)?=?New?List(Of?String)

Dim?s?As?String

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

s?=?File.ReadAllText(Application.StartupPath??"\txt.txt")

Dim?s1?As?String()?=?s.Split("@")

For?i?As?Integer?=?0?To?s1.Length?-?1

If?s1(i).Trim()??""?Then

s2.Add("@"??s1(i))

End?If

Next

TextBox1.Text?=?s2(0)

End?Sub

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

currIndex?=?currIndex?+?1

If?currIndex??s2.Count?-?1?Then

MsgBox("已經(jīng)是最后條了")

Return

End?If

TextBox1.Text?=?s2(currIndex)

End?Sub

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

currIndex?=?currIndex?-?1

If?currIndex??0?Then

MsgBox("已經(jīng)是第一條了")

Return

End?If

TextBox1.Text?=?s2(currIndex)

End?Sub

Private?Sub?Button3_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button3.Click

s2(currIndex)?=?TextBox1.Text

s?=?""

For?i?As?Integer?=?0?To?s2.Count?-?1

s?=?s2(i)

Next

File.WriteAllText(Application.StartupPath??"\txt.txt",?s)

End?Sub

End?Class

當(dāng)前文章:vb.net中修改字符串 vb 替換字符串
URL網(wǎng)址:http://chinadenli.net/article44/hgpche.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作外貿(mào)建站、微信公眾號手機(jī)網(wǎng)站建設(shè)全網(wǎng)營銷推廣網(wǎng)站建設(shè)

廣告

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

網(wǎng)站優(yōu)化排名