From: Anita on
I'm trying to use a simple function, and pass two integer values to it.

Function Readb(intDev as Integer, intBank As Integer)
Do something
End Function

Using Readb 2,0 works fine, but
Using Readb txtBank.text results in an 'Argument not optional' error
message.
in the text box is 2,0 or 2, 0 - either one, Argument not optional.

What am I missing?

Any suggestions appreciated.


From: Henning on

"Anita" <no_spam(a)mail.com> skrev i meddelandet
news:dxvin.58165$G_2.40207(a)newsfe15.iad...
> I'm trying to use a simple function, and pass two integer values to it.
>
> Function Readb(intDev as Integer, intBank As Integer)
> Do something
> End Function
>
> Using Readb 2,0 works fine, but
> Using Readb txtBank.text results in an 'Argument not optional' error
> message.
> in the text box is 2,0 or 2, 0 - either one, Argument not optional.
>
> What am I missing?
>
> Any suggestions appreciated.
>

Use Val(txtBank.text) or Cint(txtBank.text).

A TextBox Value is String, the Function expects an Integer.

/Henning


From: Anita on
"Henning" <computer_hero(a)coldmail.com> wrote in message
news:uLYb5jIuKHA.4624(a)TK2MSFTNGP02.phx.gbl...
>
> "Anita" <no_spam(a)mail.com> skrev i meddelandet
> news:dxvin.58165$G_2.40207(a)newsfe15.iad...
>> I'm trying to use a simple function, and pass two integer values to it.
>>
>> Function Readb(intDev as Integer, intBank As Integer)
>> Do something
>> End Function
>>
>> Using Readb 2,0 works fine, but
>> Using Readb txtBank.text results in an 'Argument not optional' error
>> message.
>> in the text box is 2,0 or 2, 0 - either one, Argument not optional.
>>
>> What am I missing?
>>
>> Any suggestions appreciated.
>>
>
> Use Val(txtBank.text) or Cint(txtBank.text).
>
> A TextBox Value is String, the Function expects an Integer.
>
> /Henning
>

I tested both Val(txtBank.text) and Cint(txtBank.text) same problem.


From: Bob Butler on

"Anita" <no_spam(a)mail.com> wrote in message
news:dxvin.58165$G_2.40207(a)newsfe15.iad...
> I'm trying to use a simple function, and pass two integer values to it.
>
> Function Readb(intDev as Integer, intBank As Integer)
> Do something
> End Function
>
> Using Readb 2,0 works fine, but
> Using Readb txtBank.text results in an 'Argument not optional' error
> message.
> in the text box is 2,0 or 2, 0 - either one, Argument not optional.
>
> What am I missing?

txtBank.Text returns a single string; that string may contain a comma but
that doesn't make it 2 values, it's still just a single string

x=instr(1,txtBank.Text,",")
readb cint(left$(txtbank.text,x-1)),Cint(mid$(txtBank.Text,x+1))

although you should also have some checks to ensure there is a comma and
that there is a numeric value on each side within the string.

From: Anita on

"Bob Butler" <noway(a)nospam.ever> wrote in message
news:eW6XT1IuKHA.1796(a)TK2MSFTNGP02.phx.gbl...
>
> "Anita" <no_spam(a)mail.com> wrote in message
> news:dxvin.58165$G_2.40207(a)newsfe15.iad...
>> I'm trying to use a simple function, and pass two integer values to it.
>>
>> Function Readb(intDev as Integer, intBank As Integer)
>> Do something
>> End Function
>>
>> Using Readb 2,0 works fine, but
>> Using Readb txtBank.text results in an 'Argument not optional' error
>> message.
>> in the text box is 2,0 or 2, 0 - either one, Argument not optional.
>>
>> What am I missing?
>
> txtBank.Text returns a single string; that string may contain a comma but
> that doesn't make it 2 values, it's still just a single string
>
> x=instr(1,txtBank.Text,",")
> readb cint(left$(txtbank.text,x-1)),Cint(mid$(txtBank.Text,x+1))
>
> although you should also have some checks to ensure there is a comma and
> that there is a numeric value on each side within the string.

Thank you! That worked.

This came to this simple test, but my final code will pull these two values
from a database as the code runs.
Like: 1,0 1,1 2,0 2,1,...6,0, etc.

Possibly like:
x=instr(1,txtBank.Text,",") <-- not sure how to handle

readb cint(left$(RS!Dev,x-1)),Cint(mid$(RS!Bank.Text,x+1)) <-- Sort of like
this