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

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

VB.NET中如何擴充字符串進行固定寬度顯示

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

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

PadLeft和PadRight方法

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

注意 在完成將字符串格式化為固定寬度顯示的工作時 應該使用固定寬度的字體 例如Courier等 因為固定寬度的字符占有相同的寬度 否則 填充將會無效

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

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

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

列表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字符串的操作應用

字符串的操作應用

[vb]

Module Module

Sub Main()

定義 個字符串變量

Dim str str str As String

給str str 付初值

str = Hello : str = World

Console WriteLine( 方法Concat )

連接一個或多個字符串

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)在此字符串中的第一個 最后一個匹配項的索引位置

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 ))

將字符串中的字符復制到字符串數(shù)組

Console WriteLine( 方法ToCharArray )

str = str ToCharArray(str IndexOf( NET ) )

Console WriteLine( str ={ } str )

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

在指定字符串數(shù)組的每個元素之間串聯(lián)指定的分隔符 產(chǎn)生單個串聯(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))

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

Console WriteLine( 方法Remove )

str =

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

將此字符串指定字符串字符的所有匹配項代替為其他指定字符串

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

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

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

廣告

聲明:本網(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)站優(yōu)化排名