Str Function

The Str function converts the contents of variables into a string. It handles numeric values, dates, strings and currency values.

Positive numbers are preceded by a blank space. Negative numbers are preceded by a minus sign.

note

For numeric values the string returned by the Str function is locale-independent. Hence the dot is used as the decimal separator when needed.


Kate bat pasatzen bada argumentu gisa, aldaketarik gabe itzultzen da.

Dates are converted into locale-dependent strings.

Sintaxia:


    Str (Value As Variant)
  

Itzulera-balioa:

String

Parametroak:

Value: Any value to be converted into a string.

Errore-kodeak:

5 Prozedura-dei baliogabea

Adibidea:

Below are some numeric examples using the Str function.


    Sub ExampleStr_1
        ' Note the blank space at the beginning of the returned strings
        MsgBox Str(10) ' " 10"
        MsgBox Str(10.5) ' " 10.5"
        MsgBox Str(-12345 + 1.3) ' " -12346.3"
        MsgBox Str(10000 / 3) '  " 3333.33333333333"
        ' Argumentu gisa pasatutako kateak ez dira aldatzen
        MsgBox Str("A123") ' "A123"
    End Sub
  

Erabili LTrim funtzioa itzulitako katearen hasierako zuriunea kentzeko.


    Sub ExampleStr_2
        MsgBox Str(10.5) ' " 10.5"
        MsgBox LTrim(Str(10.5)) ' "10.5"
    End Sub
  

The Str function can also handle Date variables.


    Sub ExampleStr_3
        Dim aDate as Date, aTime as Date
        aDate = DateSerial(2021, 12, 20)
        aTime = TimeSerial(10, 20, 45)
        Print Str(aDate) ' "12/20/2021"
        Print Str(aTime) ' "10:20:45"
    End sub