B4R Question How to combine variables and text ?

Ahmet KOÇ

Licensed User
I have tried many methods. "dddd" variable, "ddddd" + variable, "ddddd" .variable ... how do I combine a string variable with text in an application.


Active Member
Licensed User
@Ahmet KOÇ

I'd suggest it depends what you want to do with the variable c.

Perhaps you can provide a bit more code showing or a description of what you are trying to achieve so users in this community can make suggestions.

Ahmet KOÇ

Licensed User
Sub datagonder(xstop As String,xkapi As String, xkrc As String, xservis As String,xmac As String)
Dim metin As String =JoinStrings(Array As String("stop=", xstop, "&kapi=", xkapi,"&krc=", xkrc,"&servis=",xservis))
HttpJob.post(metin,JoinStrings(Array As String("macadres=",xmac)))
End Sub

I want to convert variables into a text with this code. It works. But standard joining operators don't work. E.g; "text" + var1 or "text" .var1 or "text" & var1 etc ...


Active Member
Licensed User
I faced that problem before, here is an example code for using RandomAccessFile to join anything, strings, bytes and numbers. First you just need to convert what you want to join to byte array then pass it to RandomAccessFile as code below;

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
    Private BC As ByteConverter
End Sub

Private Sub AppStart
End Sub

private Sub JoinStr()
    Private raf As RandomAccessFile
    Dim String1 As String = "B4R "
    Dim String2 As String = "is a great "
    Dim String3 As String "tool"
    Dim MyString As String
    Dim AllStrings (19) As Byte
    raf.Initialize(AllStrings, True)
    raf.WriteBytes(String1.GetBytes, 0, String1.Length, raf.CurrentPosition)
    raf.WriteBytes(String2.GetBytes, 0, String2.Length, raf.CurrentPosition)
    raf.WriteBytes(String3.GetBytes, 0, String3.Length, raf.CurrentPosition)
    MyString = BC.StringFromBytes(AllStrings)
End Sub