Converting from Double to String

PCowling

Member
Licensed User
Longtime User
Hello,

I am having a real issue with this. It is not a function as I expected it to be. I have searched the forums and only seem to have found what is in effect a concatenate function, ie the StringBuilder.ToString (where the StringBuilder is given a variable name, normally Sb)

So here I have two doubles east and north, holding eastings and northings as Doubles. I need to convert them to strings to be used to find OS Grid Ref Grid Letters for the UK.

I have tried:

Sb.Initialize ' sets up a StringBuilder called Sb, this is Dimmed earlier
Sb.Append(east) 'Add the contents of east to it, currently a double
eing = Sb.ToString 'try and assign the convertered string to a string variable called eing

Sb2.Initialize 'repeated the whole thing for northings
Sb2.Append(north)
ning = Sb2.ToString

Have spent along time with this. Really could do with some help.

Thanks

Other that that really excited about programming with this in a way I havnt been for years.

Thank you.

P Cowling
 

PCowling

Member
Licensed User
Longtime User
Thanks for the help

I now have:

Dim tempE As String
tempE = east
eing = tempE
Dim tempN As String
tempN = north
ning = tempN

Msgbox(eing,"Easting")
Msgbox(ning,"Northing")

Which seems to load them fine in a msgbox, so they must be strings??
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
B4A automatically converts the doubles to strings by assigning them


B4X:
Dim astring As String
Dim adouble As Double
adouble = 67.9054
astring = adouble

'do something with astring. Msgbox can be used for user to see or for your own debugging
'you can do the reverse

adouble = astring

regards, Ricky
 
Upvote 0

LudwigRS

Member
Licensed User
Longtime User
I did it with a simple function, is working fine for me.

Sub CStr(val) As String
Return val
End Sub
 
Upvote 0
Top