How do you write it?Yes, I have already created Split2 addition., but I still be occured error.
Public Sub Split2 (CurrentString As String, Split_At_Delimiter As String) As String()
Return Regex.Split(Split_At_Delimiter, CurrentString)
End Sub
Dim arrNum() As String = sf.Split2(MyTargetMoney, "\.")
But I don't know that using "\."
Sub Split2(S As String, Delimiter As Char) As String()
If S.Contains(Delimiter) = False Then
Return Array As String(S)
End If
Dim FirstDelimiterAt As Int = S.IndexOf(Delimiter)
Dim LastDelimiterAt As Int = S.LastIndexOf(Delimiter)
Dim NumFields As Int = 1
For I = FirstDelimiterAt To LastDelimiterAt
If S.CharAt(I) = Delimiter Then NumFields = NumFields + 1
Next
Dim SA(NumFields) As String
Dim FieldNumber As Int = 0
Dim FieldStart As Int = 0
For I = FirstDelimiterAt To LastDelimiterAt
If S.CharAt(I) = Delimiter Then
SA(FieldNumber) = S.SubString2(FieldStart, I)
FieldNumber = FieldNumber + 1
FieldStart = I + 1
End If
Next
SA(FieldNumber) = S.SubString(FieldStart)
Return SA
End Sub
Sub AppStart (Args() As String)
Dim TestString() As String = Array As String ( _
"Now is the time" , _
" for all good men " , _
"to come to the" , _
" aid of the party." _
)
For Each S As String In TestString
Dim Sa() As String = Split2(S, " ")
Log("""" & S & """ split into " & Sa.Length & " substrings:")
For I = 0 To Sa.Length - 1
Log(I & TAB & """" & Sa(I) & """")
Next
Next
End Sub
Waiting for debugger to connect...
Program started.
"Now is the time" split into 4 substrings:
0 "Now"
1 "is"
2 "the"
3 "time"
" for all good men " split into 6 substrings:
0 ""
1 "for"
2 "all"
3 "good"
4 "men"
5 ""
"to come to the" split into 4 substrings:
0 "to"
1 "come"
2 "to"
3 "the"
" aid of the party." split into 5 substrings:
0 ""
1 "aid"
2 "of"
3 "the"
4 "party."
Program terminated (StartMessageLoop was not called).
I wrote(Imitation of Expert'scode)
But I don't know that using "\."B4X:Public Sub Split2 (CurrentString As String, Split_At_Delimiter As String) As String() Dim mystr()= Regex.Split(Split_At_Delimiter, CurrentString) Return mystr End Sub
Sub EscapeForRegex(S As String) As String
Dim sb As StringBuilder
sb.Initialize
For I = 0 to S.Length - 1
sb.Append("\")
sb.Append(S.CharAt(I))
Next
Return sb.ToString
End Sub
Public Sub Split2 (CurrentString As String, Split_At_Delimiter As String) As String()
Return Regex.Split( EscapeForRegex(Split_At_Delimiter), CurrentString )
End Sub
describe the original problem that you are trying to solve
Really, B4XStringFunctionVb is from Margret's library(StringFunction2), but she isn't alive here.I think that is useful for non-expert and the man who understand Vb6.0 functions.I believe that the library help to import Vbprogrammers into our B4X family which helps selling B4i product more.As I'm non-expert, I know that the problem in coding ismanaged about string, array, date, etc. Manytimes, I need to use B4XStringFunctionVb forcoding.(wishs B4XStringFunctionVb is the one of internal library for all of non-experts)I might be a bit slow on the uptake here, but better late than never.
Are you creating a library with VB-compatible functions that are not already implemented in (at least) the Core of B4A/B4I/B4J ?
If yes, then: is there not already a library that does that? Or is it missing some functions? Or is it only half-done, as in VB tends to count characters (and arrays) starting from 1 ie the way humans naturally count, whereas B4A and B4J are firmly in the starting from 0 group ie the way computers naturally count.
PowerBasic has some nice string-function enhancements, eg LEFT$("abcdefg", 3) returns the usual 3 left characters "abc" but LEFT$("abcdefg", -3) returns the characters to the left not including the last 3 ie "abcde", equivalent to LEFT$("abcdefg", LEN("abcdefg") - 3). Similarly for RIGHT$, probably MID$ too. TRIM$/LTRIM$/RTRIM$ can specify which characters are to be trimmed (ie not just spaces). CHR$ can do multiple characters eg CHR$(13, 10) is same as CHR$(13) + CHR$(10). ASC can get character at any position in string, like B4X String.CharAt.
StringFunction2 is supported only B4A andB4J, so I need to be B4X supported as well.(I have connected her already, but She didn't reply to me.)Maybe I got lost, but have you seen this?
It looks that someone else already remade that library.
https://www.b4x.com/android/forum/threads/stringfunctions2.98112/
StringFunction2 is supported only B4A andB4J, so I need to be B4X supported as well.
I understand your taught,but I think Erel's products are made for all of non-experts order to escape Java coding,Obj-C ,etc,so I think B4XStringfunctionVB should be haved in B4X. Erel can get a lot of new delvelopers who need coding in mobile easily.To use B4X, just learn B4X.
The functions are unnecessary added complexity, ugly and waste of time.
If someone insist, I won't stop him.
https://www.b4x.com/android/forum/threads/b4x-b4xlib-lmvbstrfuncs.131973/#contentMy target is creating B4XStringFunctionVb before
It would be good. If you could include Margret's code, thank you in advance. It is enough to have a library VbStringFunction. It can be anyone's name. For me, I always appreciate your work. (Googletranslate)
I don't think you understand what I wanted to say.I understand your taught,but I think Erel's products are made for all of non-experts order to escape Java coding,Obj-C ,etc,so I think B4XStringfunctionVB should be haved in B4X. Erel can get a lot of new delvelopers who need coding in mobile easily.
It is the easiest way to increase the number of Vb programmers to B4X programmers.I don't think you understand what I wanted to say.
B4X is not VB6!
You can't find a new girlfriend who is exactly the same as the ex girlfriend you have lost. Just appreciate the new girlfriend is way better than your ex. VB6 is a thing in the past and will never evolve. It's time to leave her behind. In fact, I already did it 10 years ago.
You can do it yourself. Unzip that library of mine, add the functions you want, zip it again and change its name (thVBStrFuncs, for example).If you could include Margret's code, thank you in advance