|
-
Apr 28th, 2001, 11:16 PM
#1
Thread Starter
Addicted Member
2 Quick ones for ya please
Ok I got to easy questions for you
1) I got 2 text boxes 1 names pedfname and 1 pedlname I want it so if you type a name in either box and they combine for over 15 characters its beeps and doesnt let you finish????
I dont want to put a max on one box or the other just as a combination
2) little harder but for you guys a breeze, I have a PLUS sign and then a text box in the middle then a MINUS sign on the right when you press them they move the number in the text box up and down 6 digits per press I have an array set below for it problem is when you press plus when it is a 100 it gives me an error I want to lock it at 100 going up and 6 going down
thanks for your help,
Matt
vValues = Array( _
6, 13, 19, 25, 31, 38, _
44, 50, 56, 63, 69, _
75, 81, 88, 94, 100)
-
Apr 28th, 2001, 11:34 PM
#2
Thread Starter
Addicted Member
Tecchmann where are ya
-
Apr 28th, 2001, 11:39 PM
#3
Hyperactive Member
Question 1 -
This should work, and also allow you to use all of the editing keys to change the text when the are at the 15 character limit. The other way to do this is with the KeyPress Event, but then you would need to test for BackSpace and other keystrokes, so that the box can still be changed when you max out on characters.
Code:
Private Sub Text1_Change()
Static OldText As String
If Len(Text1.Text) + Len(Text2.Text) > 15 Then
Text1.Text = OldText
Beep
Exit Sub
End If
OldText = Text1.Text
End Sub
Private Sub Text2_Change()
Static OldText As String
If Len(Text1.Text) + Len(Text2.Text) > 15 Then
Text2.Text = OldText
Beep
Exit Sub
End If
OldText = Text2.Text
End Sub
-
Apr 28th, 2001, 11:44 PM
#4
Thread Starter
Addicted Member
thanks Tecch came through again????
Anybody have any Idea On that 2nd question??
2) little harder but for you guys a breeze, I have a PLUS sign and then a text box in the middle then a MINUS sign on the right when you press them they move the number in the text box up and down 6 digits per press I have an array set below for it problem is when you press plus when it is a 100 it gives me an error I want to lock it at 100 going up and 6 going down
thanks for your help,
Matt
vValues = Array( _
6, 13, 19, 25, 31, 38, _
44, 50, 56, 63, 69, _
75, 81, 88, 94, 100)
thanks again
Matt
-
Apr 28th, 2001, 11:47 PM
#5
Hyperactive Member
Question 2 -
You had shown the following array:
vValues = Array( _
6, 13, 19, 25, 31, 38, _
44, 50, 56, 63, 69, _
75, 81, 88, 94, 100)
This does not really show incrementing/decrementing by 6 - some of the numbers are different by 7 counts.
This is incrementing by 6:
6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102
Did you wnat to stick with your array, or did you make a mistake ???
Also, do you want to use an array, or would an integer variable always containing the correct number work???
-
Apr 28th, 2001, 11:49 PM
#6
Thread Starter
Addicted Member
I am sorry I do have it by some 6 and some 7 the reason is this
I am ready 1 hex from 0 to F so I divided 100 by 15(F hex) avg is 6 had to through in some 7's to make it look good.
I just want when they are at 6 or really(0 hex) when the push the minus button for the number to stay at 6 and same way with 100
Thanks Techman
-
Apr 28th, 2001, 11:52 PM
#7
Thread Starter
Addicted Member
also my fault I need if lname is > 11 I need it to lock up to just found out the game wont take lnames longer then 11
should have told you sorry
Private Sub Pedlname_Change()
Static OldText As String
If Len(Pedfname.Text) + Len(Pedlname.Text) > 15 Then
Pedlname.Text = OldText
Beep
Exit Sub
End If
OldText = Pedlname.Text
End Sub
-
Apr 28th, 2001, 11:58 PM
#8
Hyperactive Member
Code:
Private Sub Pedlname_Change()
Static OldText As String
If (Len(Pedfname.Text) + Len(Pedlname.Text) > 15) Or (Len(Pedlname.Text) > 11) Then
Pedlname.Text = OldText
Beep
Exit Sub
End If
OldText = Pedlname.Text
End Sub
-
Apr 29th, 2001, 12:11 AM
#9
Hyperactive Member
If you want to use a Plus Button and a Minus Button as you described then this should work:
Code:
Dim vValues As Variant
Dim ArrayPointer As Integer
Private Sub Form_Load()
vValues = Array(6, 13, 19, 25, 31, 38, 44, 50, 56, 63, 69, 75, 81, 88, 94, 100)
End Sub
Private Sub cmdMinus_Click()
If ArrayPointer > LBound(vValues) Then
ArrayPointer = ArrayPointer - 1
End If
Text1.Text = Str(vValues(ArrayPointer))
End Sub
Private Sub cmdPlus_Click()
If ArrayPointer < UBound(vValues) Then
ArrayPointer = ArrayPointer + 1
End If
Text1.Text = Str(vValues(ArrayPointer))
End Sub
If you don't mind sticking with a perfect increment/decrement by 6, you could also use an UpDown Control.
Try This:
- Open A New VB Project
- Add A TextBox (Text1)
- Add An UpDown COntrol (UpDown1) and place it to the right of the text box
- Copy the code below to the form
Code:
Private Sub Form_Load()
With UpDown1
.BuddyControl = Text1
.SyncBuddy = True
.Min = 6
.Max = 102
.Increment = 6
End With
End Sub
This will assign the UpDown Control to the Text1 TextBox, and cause the number to increment/decrement by 6 when you press the Up or Down button on the UpDown Control. This is a little more compact, and follows the traditional Windows look.
You will need to add the "Microsoft Windows Common Controls-2 6.0" Component to find the UpDown Control.
Hope this helps !!!!
-
Apr 29th, 2001, 12:26 AM
#10
Thread Starter
Addicted Member
Ok we are almost there 1 prob
When I click plus it goes to 13 and when I click minus it goes to 6 cant get it to any other number???
thanks Techman
below is exactly how I have it and where
General Main
global vValues as Variant
Private Sub Form_Load()
vValues = Array( _
6, 13, 19, 25, 31, 38, _
44, 50, 56, 63, 69, _
75, 81, 88, 94, 100)
End Sub
Private Sub RSMI_Click()
If ArrayPointer > LBound(vValues) Then
ArrayPointer = ArrayPointer - 1
End If
RS.Text = Str(vValues(ArrayPointer))
End Sub
Private Sub RSPL_Click()
If ArrayPointer < UBound(vValues) Then
ArrayPointer = ArrayPointer + 1
End If
RS.Text = Str(vValues(ArrayPointer))
-
Apr 29th, 2001, 12:41 AM
#11
Hyperactive Member
You forgot:
Dim ArrayPointer As Integer
in the General Main
-
Apr 29th, 2001, 12:44 AM
#12
Thread Starter
Addicted Member
ARRAY pointer was dimmed sorry forgot to write it
-
Apr 29th, 2001, 01:12 AM
#13
Thread Starter
Addicted Member
I am sorry I just read my last post I guess it looks like it fixed the problem but it didnt so here goesWhen I click plus it goes to 13 and when I click minus it goes to 6 cant get it to any other number???
thanks Techman
below is exactly how I have it and where
General Main
global vValues as Variant
dim arraypointer as integer
Private Sub Form_Load()
vValues = Array( _
6, 13, 19, 25, 31, 38, _
44, 50, 56, 63, 69, _
75, 81, 88, 94, 100)
End Sub
Private Sub RSMI_Click()
If ArrayPointer > LBound(vValues) Then
ArrayPointer = ArrayPointer - 1
End If
RS.Text = Str(vValues(ArrayPointer))
End Sub
Private Sub RSPL_Click()
If ArrayPointer < UBound(vValues) Then
ArrayPointer = ArrayPointer + 1
End If
RS.Text = Str(vValues(ArrayPointer))
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
|