Connecting Tech Pros Worldwide Forums | Help | Site Map

How do I output field as a numeric and not string?

skinnybloke
Guest
 
Posts: n/a
#1: May 3 '06
Hi - I have used scripts similar to the following to replace strings
in queries that output datafeeds in Excel format.

This time I need to output the field as a numeric and not a string.
What do I need to change in this script to make this happen?

Function PaypalQtyCheck(s As String, strGoAhead As String)
Dim a() As String
Dim v As Variant
If strGoAhead = "3" Then
s = Replace(s, "0", "1")
End If
a() = Split(s, "<")
For Each v In a
PaypalQtyCheck = PaypalQtyCheck & Mid$(v, InStr(v, ">") + 1)
Next v
End Function

Jim Andersen
Guest
 
Posts: n/a
#2: May 3 '06

re: How do I output field as a numeric and not string?


skinnybloke wrote:[color=blue]
> This time I need to output the field as a numeric and not a string.
> What do I need to change in this script to make this happen?
>[/color]

Just add "As Long", that will implicitly convert the value (if possible) to
numeric:
Function PaypalQtyCheck(s As String, strGoAhead As String) as Long

/jim


skinnybloke
Guest
 
Posts: n/a
#3: May 16 '06

re: How do I output field as a numeric and not string?


Thnaks Jim - that worked a treat.

On Wed, 3 May 2006 12:59:47 +0200, "Jim Andersen"
<jba020@politiSLET.dk.invalid> wrote:
[color=blue]
>skinnybloke wrote:[color=green]
>> This time I need to output the field as a numeric and not a string.
>> What do I need to change in this script to make this happen?
>>[/color]
>
>Just add "As Long", that will implicitly convert the value (if possible) to
>numeric:
>Function PaypalQtyCheck(s As String, strGoAhead As String) as Long
>
>/jim
>[/color]
Closed Thread