
Function Main As String
' Show number and string inter-conversion with Str, FStr, Val
' THE EXAMPLE ILLUSTRATES THE USE OF:
'   Str
'   FStr
'   Val
'   Chr
'   MessageBox

Dim s,say As String,v,vv As Double, i,k As Integer
Const title="SHOW STRING & NUMBER CONVERSIONS"

Const v=3.1415926

  k=MBB_OK + MBI_INFORMATION

  'Note the use of Chr to insert carriage return symbols (decimal code 13)
  say="Note that "+Chr(13)+Chr(13)

  'Apply Str to Pi
  s=Str(v)
  i=MessageBox(say+"Str(3.1415926)= '"+LTrim(s)+"'", title, k)

  'Apply FStr
  s=FStr(v,10,4)
  i=MessageBox(say+"FStr(3.1415926,10,4)= '"+s+"'", title,k)
  s=FStr(v,3,0)

  'Apply Val after FStr
  vv=Val(FStr(v,10,4))
  s=Str(vv)
  i=MessageBox(say+"Str(Val(FStr(3.1415926,10,4)))= '"+s+"'",title,k)

  'Apply FStr once again
  s=FStr(v,3,0)
  i=MessageBox(say+"FStr(3.1415926,3,0)= '"+s+"'", title,k)

  Main="Demo completed"
End Function
