If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > how to get numbers to show?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-09, 18:42
hoy145 hoy145 is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
how to get numbers to show?

hi, i am trying to get a program that displays how many letters you have typed into a text box, but i am unfamiliar with the "dim" command ect. so i was hoping someone can help me, i will attatch my code in a .txt,
i am not sure how to get the integer to go up 1 everytime you type, or should i be using a variable instead??

thanks in advance,

Hoy145
Attached Files
File Type: txt Code.txt (224 Bytes, 54 views)
Reply With Quote
  #2 (permalink)  
Old 06-30-09, 18:24
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
It's a scope issue. You DIMMED x within the Form_Load sub. This means that x isn't available anywhere outside this sub.

Since you want to access x in several different subs within the form, declare it (DIM) at the FORM level (before any subs or functions.)

Now, you increment x every time you make a change to the text in the textbox. Suppose you have already entered db.com (and x is equal to 6.) What happens when you press the backspace key? What happens if you highlight all the text in the textbox, and press the delete key?

VB has a built-in function which returns the length of a string... it's called LEN. You might find it useful.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Last edited by loquin; 07-01-09 at 19:59.
Reply With Quote
  #3 (permalink)  
Old 07-01-09, 08:39
hoy145 hoy145 is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
Thanks

ahh thank you ,
i'll try the LEN command now, i wondered where i had gone wrong, but i expected to as i have only just started,
thanks again,
Hoy145
Reply With Quote
  #4 (permalink)  
Old 07-01-09, 20:00
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
Just remember to not declare a variable at any higher scope level than it needs to be.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On