passing by references doesn't work 
Author Message
 passing by references doesn't work

I got the following code:

In the Keypress event of my textbox, I got the following code:

Private Sub txtRevenue_KeyPress(KeyAscii As Integer)

    Valnum (KeyAscii)

End Sub

In the general area of the form I got the following:
Sub Valnum(iTheKey As Integer)
    If (iTheKey < 48 Or iTheKey > 57) And Not iTheKey = 46 Then
        iTheKey = 0
    End If
End Sub

When iTheKey is set to 0, shouldn't it pass that value back to
KeyAscii since Visual Basic's default is a pass by reference???

It doesn't because even invalid keys are printed.  When the code is
moved into the keypress event of the textbox it works like it is
suppose to.

Please help me to understand what is going on.

Thanks,
Curtis



Sat, 18 Dec 1999 03:00:00 GMT  
 passing by references doesn't work

Quote:

> In the Keypress event of my textbox, I got the following code:

> Private Sub txtRevenue_KeyPress(KeyAscii As Integer)

>     Valnum (KeyAscii)

   ----------^        ^

These parentheses mean that you're passing the
parameter ByVal, i.e. it is equivalent to

ValNum ByVal KeyAscii

You must use either of the following syntaxes(sp?)

1) Call ValNum(KeyAscii)
2) ValNum KeyAscii

N Varacalli
--
The views expressed herein do not represent the views of my employer.

To reach me via e-mail, try (without the asterixes)
***NICHOLAS_VARACALLI at non-hp-Canada-om1.hp.com***

Pursuant to US Code, Title 47, Chapter 5, Subchapter II, Sec. 227,
any and all nonsolicited commercial E-mail sent to this address is
subject to a download and archival fee in the amount of $500 US.
E-mailing denotes acceptance of these terms.



Sun, 19 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing a Parameter its works and it doesn't work

2. Query criteria >50 doesn't work if passed from form..;(

3. Passing binary data as a (unicode) string to API is converted and doesn't work

4. fRefreshLinks Doesn't work if path doesn't exist

5. Windows Service Calling VB6 dll doesn't work but works with VB6

6. IE3 doesn't work after working with webbrowser control

7. Why LoadPicture() works on local pathes and doesn't work on the URLS

8. Work Around doesn't work for RichTextBox

9. Works/Doesn't Work

10. ActiveX-Exe: .Value=True doesn't work while direct click on button works

11. 'Next Comment' doesn't work

12. Code doesn't work (from Dev's site)

 

 
Powered by phpBB® Forum Software