|
-
Dec 23rd, 2002, 06:03 PM
#1
Thread Starter
Addicted Member
Need help on VBasic Code
Hello there.
I need help. I'm developing a Business program. Here are some of the problems I am working on.
1. How could I make a text box ONLY allowing letters and spaces, but not numbers / special characters without using the MaskedBox control and making it uppercase.
2. If I had a text box, or MaskedBox Control and I entered 30000 ... how could I automatically insert a decimal like 300.00 then when I set the focus back on the text back, put it back to 30000
3. How can I automatically align text in a list box AND textbox/richbox control so I can get text & numbers to be aligned such as:
assuming the ......... isn't there
and the text is aligned to the left and numbers aligned to the right on the same line.
DESCRIPTION OF ITEM... $1.00
SOME OTHER ITEM...... $10.00
4. How can I get records to load in a list box without waiting for the
Do while not Data1.recordset.eof
List1.additem data1.recordset![somefield]
data1.recordset.movenext
loop
If anyone has time and could reply, I would greatly appreciate it! Thanks guys!
-
Dec 23rd, 2002, 06:22 PM
#2
Hyperactive Member
#1: In the KeyPress event (off the top of my head)
VB Code:
If Not (Instr(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 ", Chr$(KeyPress))) And KeyPress <> 8 Then KeyPress = 0
#2: When it loses focus, divide the Val(myTextBox.Text) by 100 and use Format$() to get the format you want, then put it in. I suggest setting the Tag property to the old value. When it gets focus, set it back from the Tag.
#3: Set the tab stops of the listbox/textbox using the SendMessage API. Check MSDN for examples. For listboxes, however, I prefer the ListView control which supports columns.
#4: I'm not sure what you mean, but it sounds like you should data-bind the listbox.
Last edited by DovyWeiss; Dec 23rd, 2002 at 06:26 PM.
-
Dec 23rd, 2002, 06:27 PM
#3
Hyperactive Member
I edited #1 and #2 above in my answer.
Hope this solves everthing!
-
Dec 23rd, 2002, 06:57 PM
#4
1) In the KeyPress event check for valid values of KeyAscii. Note that this does not stop someone from cutting and pasting invalid text.
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 65 To 90 'A-Z
Case 97 To 122 'a-z
Case 48 To 57 'numbers
Case 8 'allow backspace
Case Else
KeyAscii = 0 'key is invalid
End Select
End Sub
2)I concur with DovyWeiss use the GotFocus/LostFocus events to set the value accordingly.
3)Try a Fixed Width Font such as Courier New
4)Not sure what you mean.
-
Dec 23rd, 2002, 11:57 PM
#5
4. Add a DoEvents after adding to the listbox. This gives the listbox a chance to refresh and display the value which has just been added.
VB Code:
Do While Not Data1.Recordset.Eof
List1.Additem Data1.Recordset![somefield]
DoEvents '<======
Data1.Recordset.MoveNext
Loop
-
Dec 24th, 2002, 12:42 AM
#6
Fanatic Member
I think he wants all the dots to be under each other, or aligned to the right. He put an example:
DESCRIPTION OF ITEM...$1.00
SOME OTHER ITEM...... $10.00
-
Dec 24th, 2002, 01:02 AM
#7
Thread Starter
Addicted Member
Thanks
The first 3 definately helped. Thanks guys!
What I mean by the 4th question is this...
Let's say I have a listbox with these selections
BLUE SKY
BLACK KNIGHT
Both are choices to which you can make on a listbox.
How would I get BLUE to be aligned to the left side of the listbox and SKY aligned to the right
Same with BLACK.. aligned to the left, and KNIGHT aligned to the right.
THANKS AGAIN!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|