473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB programming problem - help!!

Hi
I write interactive worksheets for my students using VB programming. If they enter a string of text accurately, then the string turns green - excellent. I don't write from scratch, just copy and paste from an existing document and change the wording of the string. The problem I have is that the first box will work correctly, but most of the subsequent ones, will not recognise the first keystroke, so if they enter 'John likes to eat cake.' it appears as 'ohn likes to eat cake.'
I include a sample of the code that I use.

Private Sub TextBox2_Change()
If TextBox2.Text = "I like to play computer games." Then TextBox2.ForeColor = &H8000& Else TextBox2.ForeColor = vbBlack
End Sub

Strangely, sometimes this does not happen, but I can see no reason why.

Jan
Apr 2 '08 #1
4 1029
debasisdas
8,127 Expert 4TB
Try to run the code in Lost Focus event instead of Change of the textbox.
Apr 2 '08 #2
Try to run the code in Lost Focus event instead of Change of the textbox.

Would that mean changing all the Change() bits in the code to Lost Focus() ?

I tried changing one line of the code to that and the text box disappeared and the text did not turn green

I am confused.
Apr 5 '08 #3
mafaisal
142 100+
hello

Also Try in Validate Event of Textbox

Faisal

Hi
I write interactive worksheets for my students using VB programming. If they enter a string of text accurately, then the string turns green - excellent. I don't write from scratch, just copy and paste from an existing document and change the wording of the string. The problem I have is that the first box will work correctly, but most of the subsequent ones, will not recognise the first keystroke, so if they enter 'John likes to eat cake.' it appears as 'ohn likes to eat cake.'
I include a sample of the code that I use.

Private Sub TextBox2_Change()
If TextBox2.Text = "I like to play computer games." Then TextBox2.ForeColor = &H8000& Else TextBox2.ForeColor = vbBlack
End Sub

Strangely, sometimes this does not happen, but I can see no reason why.

Jan
Apr 5 '08 #4
hello

Also Try in Validate Event of Textbox

Faisal
Mafaisal, I'm new to this - a bit more explanation please?

I've worked out why it works sometimes and not others. I have 3 worksheets in Word, linked by hyperlinks. If only one w/sheet is open it works fine. If more than one are open, only the first box works correctly. Why would this be????
Apr 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jst | last post by:
Do you need programming help? If so, pop along to our new forum and post your questions to our qualified developers. http://forum.elistarcreations.com
10
by: Rohit | last post by:
I need some ideas on how to write a program that could -- Read an MS Access database and grab information say Vehicle year, vehicle make -- Make a call to a website and enter the information...
3
by: Spartan815 | last post by:
I am writing a program that does a command line search for a specified file, or to match a pattern (i.e. search for *.h). Once it finds the file(s) it has to output absolute pathname, size, owner...
4
by: Scott C. Reynolds | last post by:
I need to do something in an asp.net application to get shipping costs from UPS. a)does anyone have any C# code for this? That would be immensely helpful as then I could examine it and apply it...
0
by: nimisha | last post by:
I'm only new to learning shell programming and we have this current task to create a .sh program (basic shell only) that can output a web access statistics report of accesses for each month in a year...
3
by: lavender | last post by:
C programmingBelow is my question and the code, but I donno the code is correct or not, can anyone please help me to correct it if I wrong. Write a program that will swap two values in an array....
4
by: crookj | last post by:
I was wondering how i can program in pcl to shift my text 10mm to the right and 6mm up. This would include all text. I print out a form and everything is shifted down and to the right. was...
1
by: alibaaba | last post by:
HI All, i am a 4th year business student and i took web design online course for fun however i did not see that last 2 chapters were python programming.This has no relevance to my major nor does...
1
by: Dennis | last post by:
HI All, i am a 4th year business student and i took web design online course for fun however i did not see that last 2 chapters were python programming.This has no relevance to my major nor does...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.