Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
Acmlm's Board - I3 Archive - Programming - VB6 - setting cursor to the end of a textbox | New poll | | |
Add to favorites | Next newer thread | Next older thread |
User | Post | ||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
I'm working on a program in VB that takes a hex address and converts it to all capitals, incase the user wasn't presing down SHIFT, but my problem is that text1.text = UCase(text1.text) does the capitalization, but sets the cursor to the beginning of the string, so if someone types in FDA, it'll appear as ADF and be processed like that, as the cursor is always at the front. How do I make the program move the cursor to the end of the string in the text box every time it goes through a text1_change() event?
The full code of the sub is as follows: A is a numeric variable, b is a string variable. Text1_Change()
So, If I pressed ADF, the cursor ould be at the beginning, followed by FDA. how can I make it so that the display would instead be ADF, followed by the cursor? |
|||
Kyoufu Kawa Intends to keep Rom Hacking in one piece until the end Since: 11-18-05 From: Catgirl Central Station Last post: 6430 days Last view: 6430 days |
| ||
To persist the cursor position:
Dim cursorPos as Long
|
|||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
Thanks very much, Kawa.
EDIT: Oh damn, that only works when I enter a number... With either A, B, C, D, E, or F, it still encounters that bug. (edited by Sukasa on 01-11-06 02:37 PM) |
|||
HyperHacker Star Mario Finally being paid to code in VB! If only I still enjoyed that. <_< Wii #7182 6487 4198 1828 Since: 11-18-05 From: Canada, w00t! My computer's specs, if anyone gives a damn. STOP TRUNCATING THIS >8^( Last post: 6431 days Last view: 6431 days |
| ||
It shouldn't make any difference. Maybe if you set the other selection-related options. (Can't recall what they are. )
Also don't forget to verify when the user pastes text in. They can do this without the keyboard in WinXP. |
|||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
I figured it out. I should'a just paid more attention to my other project there. What wored for me no matter what was the two lines
text1.SetFocus
That works all the time. (BTW, SMWOE is almost ready, I just need to finish the jump height controls, as well as add in a few more offsets and switches.) |
|||
||bass Administrator Since: 11-17-05 From: Salem, Connecticut Last post: 6432 days Last view: 6430 days |
| ||
Originally posted by SukasaOne big problem here is that if they want to type something at the begining of a box, before everything else, it will be seriously anoying. Also, using SendKeys is bad practice. |
|||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
Why? that can just use the home key or something, or the mouse, just like I did, right? The mouse and those keys don't invoke the event, so...
I have a new question: I have a form I'm making as an about form, but how do I ake it so the user can click and hold on the form and drag it? It's set to style="0", which is the borderless style. |
|||
HyperHacker Star Mario Finally being paid to code in VB! If only I still enjoyed that. <_< Wii #7182 6487 4198 1828 Since: 11-18-05 From: Canada, w00t! My computer's specs, if anyone gives a damn. STOP TRUNCATING THIS >8^( Last post: 6431 days Last view: 6431 days |
| ||
They can use home, yes, but once they type a number the cursor will jump back to the end in an annoying fashion.
Also there's an API function that controls drag+drop, but I can't recall what. |
|||
||bass Administrator Since: 11-17-05 From: Salem, Connecticut Last post: 6432 days Last view: 6430 days |
| ||
Originally posted by SukasaO[home][right]k[home][right][right].[home][right][right][right] [home][right][right][right][right]A[home][right][right][right][right][right]s[home][right][right][right][right][right] [click]i[click]f[click] [click]t[click]h[click]a[click]t[click] [click]m[click]a[click]k[click]e[click]s[click] [click]a[click]n[click]y[click] [click]s[click]e[click]n[click]c[click]e[click]. THIS TEXT WAS TYPED IN FIRST. |
|||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
I get your point. I'll work at that as well. | |||
wboy Since: 01-05-06 Last post: 6614 days Last view: 6614 days |
| ||
Rather than use sendkeys to take you to the end, use the Len function:
Text1.SelLength = Len(Text1.Text) Though to retain the cursor position and limit entry to only valid hex characters, use and evaluate Text1's Keypress event: Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case vbKey0 To vbKey9, vbKeyA To vbKeyF: 'Upper - Accept - Keycode constants are safe to use in this example Case Asc("a") To Asc("f"): 'Lower - Convert to Upper KeyAscii = KeyAscii - 32 Case Else 'Ingore Debug.Print KeyAscii KeyAscii = 0 Beep End Select End Sub |
|||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
Hey, thanks!
I looked through your example, it looks nice. You don't mind then, if I use it and credit you, I hope. *copies to clipboard* |
|||
wboy Since: 01-05-06 Last post: 6614 days Last view: 6614 days |
| ||
Yeah no worries, feel free to use the code...
if you need cut and paste support you'll need to insert... Case 3, 22, 24: 'Ctrl+C (Copy), Ctrl+V (Paste), Ctrl+X (Cut) ...the line above the: Case Else 'Ingore though then (as mention one of the posts above) you'll need to re-validate the pasted text, as it will permit whatever text in on the clipboard. Oh, and you can use Text1.Maxlength = 8 to limit the amount of character that can be inputted/pasted. |
|||
Sukasa Birdo Not quite as active as before. Xkeeper supporter Xk > ||bass I IP Banned myself! Twice! Since: 11-17-05 From: Somewhere over there Last post: 6431 days Last view: 6430 days |
| ||
Thanks!
I added Case 8 just at the top though, to allow the backspace key. You really helped me, wboy! |
|||
wboy Since: 01-05-06 Last post: 6614 days Last view: 6614 days |
| ||
oops.... yeah vbKeyBack (8) would also come in handy!
you can also do things like trap/case vbKeyEscape and clear/reset the textbox. e.g. text1.text = vbNullString (same as "") |
Add to favorites | Next newer thread | Next older thread |
Acmlm's Board - I3 Archive - Programming - VB6 - setting cursor to the end of a textbox | | |