Split function in VB 6.0 actually splits a string based on delimiter provided and returns it into an
array.
Suppose there is a string like this "Ram#23#Male#M.G.Road"
Now if we split this string with delimiter # into a variant array name arr the result will be
arr(0)="Ram"
arr(1)="23"
arr(0)="Male"
arr(0)="M.G.Road"
Here is the program written into a function
private sub SplitString(strTxt as string,delimiter as string)
dim var
dim i as integer
var = VBA.Split(strTxt,delimiter)
for i=lbound(var) to ubound(var)
debug.print var(i)
next i
end sub
'In form load event the function is called with 2 parameters, a string and a delimiter #
private sub Form_Load()
call splitstring( "Ram#23#Male#M.G.Road","#")
end sub
array.
Suppose there is a string like this "Ram#23#Male#M.G.Road"
Now if we split this string with delimiter # into a variant array name arr the result will be
arr(0)="Ram"
arr(1)="23"
arr(0)="Male"
arr(0)="M.G.Road"
Here is the program written into a function
private sub SplitString(strTxt as string,delimiter as string)
dim var
dim i as integer
var = VBA.Split(strTxt,delimiter)
for i=lbound(var) to ubound(var)
debug.print var(i)
next i
end sub
'In form load event the function is called with 2 parameters, a string and a delimiter #
private sub Form_Load()
call splitstring( "Ram#23#Male#M.G.Road","#")
end sub
No comments:
Post a Comment