Hello to everyone,
i need to replace hex(00) (null value) in a string by "" for removing it...
thanks for help
i need to replace hex(00) (null value) in a string by "" for removing it...
thanks for help
if stringname = null then
stringname=""
end if
Hello to everyone,
i need to replace hex(00) (null value) in a string by "" for removing it...
thanks for help
Dim strin As String = "abcdefghijklmnopq"
Msgbox(strin.Replace("c",""),"Replaced")
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim s As String = "abc" & Chr(0) & "def"
Log(s & " " & s.length)
s.Replace(Chr(0),"")
Log(s & " " & s.Length)
s = Remove0(s)
Log(s & " " & s.Length)
End Sub
Sub Remove0 (s As String) As String
Dim i As Int
Dim NewString As String 'We will build the new string here
Dim LeftIndex As Int = 0 'Keep track of what has already been copied over
For i = 0 To s.Length - 1 'go through each character
If s.CharAt(i) = Chr(0) Then
NewString = NewString & s.SubString2(LeftIndex,i) 'copy the string up to the 0
LeftIndex = i + 1 'increment the Left index just past the 0
End If
Next
If LeftIndex < s.Length Then 'copy the rest of the string over
NewString = NewString & s.SubString(LeftIndex)
End If
Return NewString 'return the result
End Sub
@MitchBu: seems as though Replace does not work with Chr(0).
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim strin As String = "abc" & Chr(0) & "defghijklmnopq"
Msgbox(substitute(strin,Chr(0),"x"),"")
End Sub
Sub substitute(chain As String, search As String, replaced As String)
If chain.IndexOf(search) = 0 Then Return
Dim gauche, droite As String
Do While chain.IndexOf(search)>0
chain = chain.substring2(0,chain.IndexOf(search)) & replaced & _
chain.SubString(chain.IndexOf(search)+search.Length)
Loop
Return chain
End Sub