473,766 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB6/Blinking Cursor/Textbox/Move Cursor

20 New Member
Right now I have a touchscreen with a virual keyboard.

I would like to create arrow keys. If the user messed up the inputted text, he can move the blinking cursor left one space at a time between inputted characters to add a letter. Then a button to move the blinking cursor back to the end of the inputted text.

Private Sub Left Arrow_Click()
If Text1.SelStart Then Text1.SelStart = Text1.SelStart - 1
Text1.SetFocus
End Sub

Private Sub Right Arrow_Click()
If Text1.SelStart < Len(Text1.Text) Then Text1.SelStart = Text1.SelStart + 1
Text1.SetFocus
End Sub

Private Sub Enter Letter_Click()
Text1.Text = Text1.Text + Command1(Index) .Caption

For i = 0 To Command1.ubound
Command1(i).Cap tion = LCase(Command1( i).Caption)
Next

cmdLowercase.Vi sible = False
End Sub

When the cursor is moved left, I would like to have the next letter inserted where the cursor is blinking, not at the end of what's already entered.

With what I have so far, the cursor will move left after some letters are entered into the textbox. But when the next letter is selected it inserts it at the very end.

Basically in my textbox I want to enter more text wherever the cursor is blinking...

If I select a random part of the entered text and enter another letter or hit the backspace button, it adds the letter at the end or backspaces from the end.

Can anyone help me please?
Oct 1 '08 #1
5 8515
smartchap
236 New Member
In the Enter Letter_Click event u have written

Text1.Text = Text1.Text + Command1(Index) .Caption

which will obviously add new character at the end of the Text1. First find out the current position of the cursor (in the text box) and then change text in text box when u enter a character.

Also please let me know u want to enter character from key board (actual) or the one u have created on screen.

If any other problem please post zip file of the project so that I will try to correct it.
Oct 1 '08 #2
michels287
20 New Member
I wish to use the keyboard on screen, not the actual keyboard.

Thanks.

Currently working with another recommendation that looks like:

Text1.Text = Left(Text1.Text , Text1.SelStart - 1) & Command1(Index) .Caption & Mid(Text1.Text, Text1.SelStart + 1)

But I get errors when I place this in my Command1_Click( Index As Integer)

'Invalid procedure call or argument"
Oct 1 '08 #3
smartchap
236 New Member
Correct your MID function. It must have three arguments.
Oct 1 '08 #4
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

@SmartChap: Not Necessarily. MID is an Over-loaded function, Omitting the last Argument, returns from the Middle till the end..

@OP,
Once, you change the Text, Your SelStart also changes, you have to reset it..
So that you can hit keys continously..

Try This :
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = Text1.SelStart
  3. Text1.text = Left(Text1.text, Text1.SelStart) & Command1(Index).Caption  & Mid(Text1.text, Text1.SelStart + 1)
  4. Text1.SelStart = i + 1
  5.  
Regards
Veena
Oct 2 '08 #5
michels287
20 New Member
Thanks! Resolved.

Means a lot.
Oct 13 '08 #6

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

Similar topics

7
5802
by: Seash | last post by:
Hi friends , here is the sample code private void txtbox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus(); }
22
4546
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't that difficult, but to find the next line is more difficult. For exemple: if my cursor is on line 200, it has to start searching on line 201, and not on line 1. Anybody has any ideas?
2
1466
by: dinny | last post by:
I have a form and a multiline textbox with a message. The problem is that I can see the cursor, is there any way so move the focus away from the textbox so that I don't see the cursor on the form (unless someone actively clicks on the form, that is ok) I tried this, but it didn't work Public Declare Auto Function HideCaret Lib "user32.dll" ( _ ByVal hwnd As IntPtr) As Boolean
1
3160
by: Marc Robitaille | last post by:
Hello I build a usercontrol. On this new control, I added two controls, a TextBox and a ComboBox. My ComboBox is filled with a DataTable. When the user types something in the TextBox, I apply a filter to the DataView of the DataTable of my ComboBox. If there is more than one element, I dropdown the list. If I have one element, it is automatically selected. My problem is that the cursor works badly. When I type for the first time in...
3
7332
by: johnk | last post by:
Hi, I am trying to get a textbox in a form to display a partial item entry, i.e. "WER-5-" as most item serial numbers contian this value. I want the cursor at the end of this text but it is always at the beginning. How do I get it at the end. I remember at one faking character input to do something similar but can't remember how I did it.
3
11996
by: fbergroth | last post by:
Hi, I'm quite new to C# allthough I've been programming in other languages for quite a while. I'd like to change the blinking cursor inside a TextBox, I guess I must derive the class and override the OnPaint()-method, however I have no clue what to do next. I want to be able to switch the blinking cursor to a solid, non-blinking, cursor and preferable have it with a color. So, how should I do that?
4
64886
by: Brandon McCombs | last post by:
Does anyone know of an easy way to set the position of the cursor in a TextBox? If I set text in the box that is longer than the length of the TextBox the position of the cursor is at the very end of the line and a user would have to use the arrow keys to move it back to the beginning of the line of text. I'd prefer to set the cursor position automatically to just before the first character of the text. thanks
5
5471
by: shivasusan | last post by:
Hi! I want to blink the textbox and place the cursor in that text box. (If the user didn't enter the name and click the submit button. That time, the text box want to blink "two or three times") How? I didn't have any idea.... so please help me.. <form action="demo_disquery.asp" method="get"> Your name: <input type="text" name="name" size="25" /> Age: <input type="text" name="age" size="3" /> <input type="submit" value="Submit" />...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10008
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9837
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.