I'm new to b4a: Can anybody port vb6 function printf to b4x
Public Function printf(mask As String, ParamArray tokens()) As String
Dim I As Long
For I = 0 To UBound(tokens)
mask = Replace$(mask, "{" & I & "}", tokens(I))
Next
printf = mask
End Function
better than this:
Public Sub printf(mask As String, tokens() As String) As String
Dim i As Short
For i = 0 To tokens.Length-1
mask = mask.Replace("{" & i & "}", tokens(i))
Next
Return mask
End Sub
vb6 : s = printf("Today is {0}. Tommorow is {1}.", "monday","tuesday")
b4a: s = printf("Today is {0}. Tommorow is {1}.", array("monday","tuesday"))
2. how can I insert CLRF like \n instring
s= "monday\n tuesday"
without doing s = "test " & CLRF & "test 2"
so I can use my printf function like:
lbl1.text = printf("Today is {0}.\nTommorow is {1}", array("monday","tuesday"))
Public Function printf(mask As String, ParamArray tokens()) As String
Dim I As Long
For I = 0 To UBound(tokens)
mask = Replace$(mask, "{" & I & "}", tokens(I))
Next
printf = mask
End Function
better than this:
Public Sub printf(mask As String, tokens() As String) As String
Dim i As Short
For i = 0 To tokens.Length-1
mask = mask.Replace("{" & i & "}", tokens(i))
Next
Return mask
End Sub
vb6 : s = printf("Today is {0}. Tommorow is {1}.", "monday","tuesday")
b4a: s = printf("Today is {0}. Tommorow is {1}.", array("monday","tuesday"))
2. how can I insert CLRF like \n instring
s= "monday\n tuesday"
without doing s = "test " & CLRF & "test 2"
so I can use my printf function like:
lbl1.text = printf("Today is {0}.\nTommorow is {1}", array("monday","tuesday"))