473,385 Members | 1,645 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,385 software developers and data experts.

Highlighting characters in VB6 Textbox while typing itself....

Hi Gurus,
I need one solution
I'm using VB6, one of its Form contains a TextBox
What i need is whatever characters I type in it that
should be highlighted
ex

First when I type "a" -> "a" should be selected
second when I type "b" -> "ab" should be selected
third when I type "c" -> "abc" should be selected
fourth when I type "d" -> "abcd" should be selected
likewise it go.

ie overall characters upto the cursor end should be selected.

Help me out.
Nov 22 '07 #1
4 2018
QVeen72
1,445 Expert 1GB
Hi,

To Highlight Text in a Textbox, you can use this code:

Expand|Select|Wrap|Line Numbers
  1. Text1.SelStart =0
  2. Text1.SelLength = Len(Text1.Text)
  3.  
Write this in Got_Focus Event.
If you write this in Change Event (as per your Requirement),
The Highlighted Text would keep on deleting with every key typed..
Not very sure, why do you have such a requirement...

Regards
Veena
Nov 22 '07 #2
Veena,
Thnks for your response.
Actually my work behind reading Barcode thru Barcode Reader into the
TextBox, The Maxlength of the TextBox is 12.
If I Input some characters manually into the TextBox Say "abc" (without quotes)
now the cursor is in 4th place from there it won't allow Barcode Reader to read.
It should start from 1st place only by erasing already existing 3 characters.
This is my situation.

Can U come out of this.
Nov 22 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

Then, write the code (my previous post) in got_focus event, I think it would solve your problem..

Regards
Veena
Nov 23 '07 #4
dontbe
3
Hi,

Maybe You can add this code on Change event in your textbox
Expand|Select|Wrap|Line Numbers
  1. Dim ChrSet As String, chrpos As Integer, getchr As String
  2. ChrSet = Text1.Text
  3. If IsNumeric(ChrSet) = False Then
  4.     If Len(ChrSet) <> 0 Then
  5.         chrpos = InStr(1, ChrSet, Right(ChrSet, 1), vbTextCompare)
  6.         getchr = Right(ChrSet, 1)
  7.         Text1.SelStart = chrpos - 1
  8.         Text1.SelLength = Len(getchr)
  9.     End If
  10. End If
  11.  
This Code Will Highlight the last character, and you replaced it with the right for for you card reader!
Nov 23 '07 #5

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

Similar topics

0
by: Mark Johnson | last post by:
The last reply got sort of cutoff. So here again: So for anyone interested, here's the simple regexp patterns for the substitutions required. The textbox control is being 'zoomed' in a popup...
1
by: VMI | last post by:
I have two textbox controls and I want my application to automatically highlight in the second textbox control the same amount of chars (and the same position) that are being highlighted in the...
7
by: JM | last post by:
Hi, I transferred an AJAX application to the server to be used across the Internet. On my localhost, it works great. But when I transferred it to the server, the user control freezes for a...
7
by: scottiedog | last post by:
Hi How can I send a char to Textbox so that KeyPress event is called? I have a button and with a click I would like to send a char, e.g. "C", to the Textbox. But Textbox1_KeyPress is not catching...
2
by: Abraham Andres Luna | last post by:
hello everyone, i have an aspx page that when first loaded all the textboxes are empty. the client side javascript will fill some of the textboxes based on what the user selects. for some reason...
1
by: darkk | last post by:
I was wondering how I could highlight everything in a textbox just by clicking on it. example: textbox1 has "0" as text, I want to click and type 1, instead of having to select, then delete the 0...
14
by: > Adrian | last post by:
Is there a way of stopping text from highlighting in textbox? Many thanks, Adrian.
1
by: bhappy | last post by:
Hai, I want to validate a textbox in clientside and im using the following code. Regular Expression Validator Exp: " .{250}.* " --> It means minimum length of textbox should be...
12
by: AdamOnAccess | last post by:
Hi, While the user is typing into a text box, I need to display the length of the string they are typing. My code is... displayCountLabel.caption = len(me!fieldTheyAreTypingIn) Problem is...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.