Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 13th, 2007, 08:45 PM
Registered User
 
Join Date: Feb 2007
Location: Teaneck, NJ, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using the Asc function

Hi,

I'm new to this site and am hoping someone can help. I'm trying to find the ascii value of text entered into a text box. I've written the following code on the Key press event of a text box, but every time I type something in, I get a "Invalid procedure call or argument" error. Do I need to have a specific reference turned on or is there an issue with my code?

Thanks in advance for your help!

    Private Sub txt_String_KeyPress(KeyAscii As Integer)

         Dim Asc_Value As String

         Asc_Value = Asc(Me.txt_String.Text)
         MsgBox Asc(Asc_Value)


    End Sub



--LANGSHA--
 
Old February 20th, 2007, 04:42 AM
Registered User
 
Join Date: Oct 2006
Location: chennai, tamil nadu, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to kumarj
Default

Try to split the string and use asc() function

 
Old March 29th, 2008, 02:54 AM
Registered User
 
Join Date: Mar 2008
Location: Eorde, TN, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Option Explicit
Public ascval As String
-------------------------------------------------------
Private Sub txt_String_KeyPress_KeyPress(KeyAscii As Integer)
ascval = ascval & KeyAscii
End Sub
---------------------------------------------------------------
Private Sub txt_String_KeyPress_KeyUp(KeyCode As Integer, Shift As Integer)
txt_String_KeyPress = ascval
End Sub
 
Old November 25th, 2008, 12:13 PM
Registered User
 
Join Date: Nov 2008
Location: Bronx, NY, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

KeyAscii is the Ascii value for the key you pressed while in your textbox named txt_String. The KeyPress event tracks each time you press a key, hence the name.

You are receiving the error "Invalid procedure call or argument" because you are providing an invalid argument to the Asc() function. The Asc() function takes a single text character. You can only get the Ascii value of a single character.

That being said, what are you trying to accomplish?

Allan






Quote:
quote:Originally posted by langsha
 Hi,

I'm new to this site and am hoping someone can help. I'm trying to find the ascii value of text entered into a text box. I've written the following code on the Key press event of a text box, but every time I type something in, I get a "Invalid procedure call or argument" error. Do I need to have a specific reference turned on or is there an issue with my code?

Thanks in advance for your help!

    Private Sub txt_String_KeyPress(KeyAscii As Integer)

         Dim Asc_Value As String

         Asc_Value = Asc(Me.txt_String.Text)
         MsgBox Asc(Asc_Value)


    End Sub



--LANGSHA--




Similar Threads
Thread Thread Starter Forum Replies Last Post
Get charactor from Asc value hiruni Beginning VB 6 2 February 7th, 2006 10:51 PM
ASC function Error JpJoe Access 3 May 22nd, 2005 01:36 AM
ORDER BY id ASC gilgalbiblewheel Classic ASP Databases 1 January 5th, 2005 12:20 AM
How to put Desc/Asc triangle symbol on List View? hplim18 VB How-To 1 May 10th, 2004 12:17 PM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.