VB分割字串,VB字串從指定字串分割

2022-03-07 11:08:02 字數 4315 閱讀 2028

1樓:牛a和牛c間徘徊

汗...split函式是可以指定拆分次數的.....在分隔符後面指定拆分成2份就行了.....樓上的竟然搞那麼複雜

debug.print split(str, " ", 2)

2樓:仍夢

strname as string, paramarray intscores() as variant)

dim inti,k as integerdim substr as string

k=0substr=""

debug.print strname; " scores"

' 用 ubound 函式決定陣列的上限。

for inti = 0 to ubound(intscores())

debug.print " "; intscores(inti)

substr=substr+intscores(inti)k=k+1

if(k=2) then

debug.pring " "; substrk=0substr=""

end if

next inti

end sub

3樓:匿名使用者

jinfahua是正解,結貼吧

附上方法2:

用到split函式

private sub command1_click()dim s as string, c1 as string, c2 as string

dim i as integer

s = "abc def h"

a = split(s)

c1 = a(0)

for i = 1 to ubound(a)c2 = c2 & " " & a(i)

next

c2 = trim(c2)

print c1

print c2

end sub

4樓:匿名使用者

沒有容錯 處理

private sub splitfunc(dim instring as string,dim outstr1 as string,dim outstr2 as string)

dim length

length=instr(instring," ")outstr1=left(instring,length-1)outstr2=right(instring,len(instring)-length)

end sub

dim str1,str2 as stringsplitfunc "abc def h",str1,str2msgbox "part1: " & str1 & vbnewline & "part2: " & str2,,"splitfunc"

5樓:匿名使用者

dim s as string, c1 as string, c2 as string

dim i as integer

s = "abc def h"

i = instr(1, s, " ")

c1 = left(s, i - 1)

c2 = mid(s, i + 1)

vb字串從指定字串分割

6樓:四舍**入

private sub command1_click()dim s as string

s = "123456----hdahdkahd----2013.1.1"

dim a

a = split(s, "----")

if isarray(a) then

text1.text = a(1)

end if

end sub

7樓:veket的小號

親 , 用split函式 分割字串得到陣列private sub command1_click()dim s as string

s = "123456----hdahdkahd----2013.1.1"

dim a

a = split(s, "----")

if isarray(a) then

text1.text = a(1)

end if

end sub

8樓:

x=split("123456----hdahdkahd----2013.1.1","----")

text1.text=x(1)

9樓:匿名使用者

private sub command1_click()dim s as string

dim st as string

dim i, l as integer

s = "123123-123-sdfsdfsdfs--2342342"

st = ""

l = len(s)

for i = 1 to l

if 97 < asc(mid(s, i, 1)) and asc(mid(s, i, 1)) < 122 then

st = st & mid(s, i, 1)end if

next i

text1.text = st

end sub

要分啊 呵呵

j**a分割字串 10

vb分割字串

10樓:匿名使用者

這個很簡單  用mid函式就行了

private sub command1_click()dim arr() as string

dim a as string

dim i as integer

a = "abcdef"

redim arr(len(a))  '重新定義陣列長度為字串長度for i = 1 to len(a)  '在字串內迴圈arr(i) = mid(a, i, 1)  '利用mid函式分割字串並賦值到陣列

print arr(i)  '輸出分解的字元  測試用 可刪掉next i

end sub

11樓:鼓風管

的目的是要vb將字串分成單個字元。 如果要放入一個陣列中,可以這樣: private sub command1_click() dim s as string dim ars() as string dim i as long, m as long s = "abcdefg" m = len(s) redim ars(m - 1) for i = 1 to m ars(i - 1)

12樓:是旭方銀柳

汗...split函式是可以指定拆分次數的.....在分隔符後面指定拆分成2份就行了.....樓上的竟然搞那麼複雜

debug.print

split(str,"",2)

vb中,如何將字串分割成所需要的字元?

13樓:飄葉雜談

dim s as string

dim sv1() as string

dim sv2() as string

s="s11+s20+s31+dl1"

sv1=split(s,"+",-1)

redim sv2(ubound(sv1))for x= 0 to ubound(sv1)sv1(x)=left(sv1(x),2)sv2(x)=right(sv1(x),1)debug.print sv1(x) & " " & sv2(x)

next

以上程式,儲存並輸出了陣列內容

14樓:

不要字串裡面的「+」號可以用replace函式

replace(str,"+","")

15樓:匿名使用者

private sub command1_click()dim s as string

s = "s11+s20+s31+dl1"

dim a, b

a = split(s, "+")

b = array(1, 0, 1, 1)end sub

16樓:匿名使用者

dim str as string

dim arr as string ()

str = "s11+s20+s31+dl1"

arr = split(str, "+")

17樓:匿名使用者

用split()函式,具體用法請參見msdn

vb6中字串相加,vb6中字串相加

因為你 a,b,c 三個變數定義錯誤 不應該是字串型別 而應該是 數值型 dim a as long b as long c as long vb語言中怎麼輸入加法 比如 text3.text text1.text text2.text 是字串相加,結果就是把兩個字串連起來,正確應該是text3.t...

VB中,怎樣在已知的字串中插入字元

很簡單嘛,先將原字串拆分成兩半,加入後再合上即可。dim t as string dim k as string t abcdfghijklmn k mid t,1,4 e mid t,5 這個 是將字母e插在從左向右第5個位置上。原字串是 abcdfghijklmn 插入後的字串是 abcdefg...

任意輸入字元組成字串,對該字串中的字元按ASCII碼值升序排列後輸出,程式設計實現此功能

在手機知道中已有 知道君 正確的回答,電腦中為何看不見呢 public class form1 不限制輸入的字元個數 private sub button1 click byval sender as system.object,byval e as system.eventargs handles...