Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
User | Post |
wboy Posts: 3/15 |
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 "") |
Sukasa Posts: 573/2068 |
Thanks!
I added Case 8 just at the top though, to allow the backspace key. You really helped me, wboy! |
wboy Posts: 2/15 |
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 Posts: 550/2068 |
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 Posts: 1/15 |
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 Posts: 543/2068 |
I get your point. I'll work at that as well. |
||bass Posts: 72/594 |
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. |
HyperHacker Posts: 801/5072 |
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. |
Sukasa Posts: 541/2068 |
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. |
||bass Posts: 61/594 |
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 Posts: 540/2068 |
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.) |
HyperHacker Posts: 735/5072 |
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 Posts: 538/2068 |
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. |
Kyoufu Kawa Posts: 406/1353 |
To persist the cursor position:
Dim cursorPos as Long
|
Sukasa Posts: 537/2068 |
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? |