(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-18-24 03:00 AM
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: 6299 days
Last view: 6298 days
Posted on 01-11-06 02:58 AM Link | Quote
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()
On Error GoTo ErrHandler
Text1.Text = UCase(Text1.Text)
b = "&H" + Text1.Text
a = Val(b)
Get #1, a, a
Text2.Text = a
Exit Sub
ErrHandler:
Text2.text = ""
Exit Sub
End Sub


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: 6298 days
Last view: 6298 days
Posted on 01-11-06 12:49 PM Link | Quote
To persist the cursor position:

Dim cursorPos as Long
...
cursorPos = Text1.SelStart
'process shit
Text1.SelStart = cursorPos
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: 6299 days
Last view: 6298 days
Posted on 01-11-06 03:34 PM Link | Quote
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: 6298 days
Last view: 6298 days
Posted on 01-11-06 09:42 PM Link | Quote
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: 6299 days
Last view: 6298 days
Posted on 01-12-06 11:52 PM Link | Quote
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
SendKeys "{end}"


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: 6299 days
Last view: 6298 days
Posted on 01-13-06 12:51 AM Link | Quote
Originally posted by Sukasa
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
SendKeys "{end}"


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.)
One 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: 6299 days
Last view: 6298 days
Posted on 01-13-06 10:22 PM Link | Quote
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: 6298 days
Last view: 6298 days
Posted on 01-14-06 07:13 AM Link | Quote
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: 6299 days
Last view: 6298 days
Posted on 01-14-06 11:35 AM Link | Quote
Originally posted by Sukasa
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.
O[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: 6299 days
Last view: 6298 days
Posted on 01-14-06 01:48 PM Link | Quote
I get your point. I'll work at that as well.
wboy









Since: 01-05-06

Last post: 6481 days
Last view: 6481 days
Posted on 01-16-06 08:08 PM Link | Quote
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: 6299 days
Last view: 6298 days
Posted on 01-19-06 09:47 PM Link | Quote
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: 6481 days
Last view: 6481 days
Posted on 01-20-06 08:35 AM Link | Quote
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: 6299 days
Last view: 6298 days
Posted on 01-25-06 03:45 PM Link | Quote
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: 6481 days
Last view: 6481 days
Posted on 01-25-06 11:00 PM Link | Quote
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 |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.011 seconds; used 421.55 kB (max 533.02 kB)