Created
January 12, 2018 17:32
-
-
Save ndthanh/18d5cd144a33d87b14e76c16df5939ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function FormatString(ByVal sFormat As String, _ | |
ParamArray arg() As Variant) | |
Dim idx As Integer | |
For idx = LBound(arg) To UBound(arg) | |
sFormat = Replace(sFormat, "{" & idx & "}", arg(idx)) | |
Next idx | |
FormatString = sFormat | |
End Function | |
Sub UnitTest() | |
Dim strURL As String, strUser As String, strToken As String, strOp As String | |
strUser = "heo" | |
strToken = "930kdoakdlcaj" | |
strOp = "topup" | |
strURL = "https://hocexcel.online/register.js?username={0}&token={1}&operation={2}" | |
'strURL= "https://hocexcel.online/register.js?username=" & struser & "&token=" & strToken & "&operation=" & strOp | |
Debug.Print FormatString(strURL, strUser, strToken, strOp) | |
'https://hocexcel.online/register.js?username=heo&token=930kdoakdlcaj&operation=topup | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment