Sub FieldReplace(FieldNo As Int,Delim As String,Source As String,ReplacementStr As String) As String
'Stops arrayindex out of bounds error
If FieldNo < 0 Then Return Source
Dim T() As String = Regex.Split(Delim,Source)
'Stops arrayindex out of bounds error
If FieldNo >= T.Length Then Return Source
T(FieldNo) = ReplacementStr
'Build Return String
Dim ReturnStr As String
For i = 0 To T.Length - 1
ReturnStr = ReturnStr & T(i)
If i < T.Length - 1 Then ReturnStr = ReturnStr & Delim
Next
Return ReturnStr
End Sub
Dim Str As String = "1,2,3,4"
Log(FieldReplace(2,",",Str,"A")) 'Positions are zero based same as arrays
Sub GetField(FieldNo As Int,Delim As String,Source As String) As String
'Stops arrayindex out of bounds error
If FieldNo < 0 Then Return ""
Dim T() As String = Regex.Split(Delim,Source)
'Stops arrayindex out of bounds error
If FieldNo >= T.Length Then Return ""
Return T(FieldNo)
End Sub
Dim Str As String = "1,2,3,4"
Dim TexttoReplace As String = GetField(2,",",Str)
Log(FieldReplace(2,",",Str,"A"))
exactly!It should dont need this thread knowing the basics!
Sub bt_1_Click
Dim xx As String
xx = 1
Stre = Items(0) & "," & Items(1) & "," & xx & "," & Items(3)
File.WriteString(File.DirRootExternal, "TT.txt", _
Stre)
End Sub
http://www.b4x.com/android/forum/threads/solved-tts-service-for-2-activitys.49877/#post-311439
He is not implicating... but there are noob questions... and then there are the "I don't care about the search engine on the top right of the this site" questions...Thanks @stevel05B4X:Sub bt_1_Click Dim xx As String xx = 1 Stre = Items(0) & "," & Items(1) & "," & xx & "," & Items(3) File.WriteString(File.DirRootExternal, "TT.txt", _ Stre) End Sub
@Manfred i dont now why every time you reply to my posts you have to implicate...
B4X:http://www.b4x.com/android/forum/threads/solved-tts-service-for-2-activitys.49877/#post-311439