|
-
May 17th, 2005, 12:58 PM
#1
(SOLVED)Bleh!
Hi, I am new...I am more used to using VB.NET as that is the program I use in college.
However, I am working at a job and using MS Access. This as you may know, uses vb6!
Well in .NET I could fix this problem pretty easily, but vb6 is quite different .
The problem I am having is I have several date time pickers, and depending on the input from the user, I only want to have a certain amount of them visible.
My code is very basic right now because I usually delete stuff after I have tried it....
The basics are
VB Code:
For Counter = 1 to Date ' date is the # of boxes picked
DTPicker1.visible = true
Next
That makes the first dtpicker visible, obviously, however, I have 9 others I want visible as well.
In .NET there is a trimend command and I can simply remiove the 1 and add a 2 and so forth, but in vb6 I cannot do this.
Can anyone see a way around this? (besides bad programming )
Sorry if I didnt explain this well enough, if you have any questions just post here
Last edited by kfcSmitty; May 18th, 2005 at 02:57 PM.
-
May 17th, 2005, 01:10 PM
#2
Re: Bleh!
Welcome to the forums.
Try to be a bit more descriptive in your question titles.
The easiest solution would be to put your DTPickers in a control array. Something like dtpDate(0) through dtpDate(8) for 9 controls.
Then you could loop through them with
VB Code:
For Counter = 0 to 8
dtpDate(i).Visible = True
Next
You wouldn't hard code that 8. That would be a variable for how many should have their visible property toggled to True.
-
May 17th, 2005, 01:15 PM
#3
Re: Bleh!
Sorry about the title...Ill remember that for next time! 
And as for your solution, I already tried that, and it kept giving me an error (cant remember what, ive seen so many today).
Was soemthing along the lines of .visible is not a valid property for DTPicker(Counter)
*edit* the actual error was "invalid qualifier"
Last edited by kfcSmitty; May 17th, 2005 at 01:30 PM.
-
May 17th, 2005, 01:32 PM
#4
Re: Bleh!
Post the code that was giving you the error as well as how you were using it.
-
May 17th, 2005, 01:36 PM
#5
Re: Bleh!
Don't mind the ugly coding ^^ This is a rough draft.
Looking at it actually makes me want to cry right now
VB Code:
Option Compare Database
Dim DTPDate(9) As String
Dim Counter As Integer
Private Sub Form_Load()
DTPDate(0) = DTPicker1
DTPDate(2) = DTPicker2
DTPDate(2) = DtPicker3
DTPDate(3) = DTPicker4
DTPDate(4) = DTPicker5
DTPDate(5) = DTPicker6
DTPDate(6) = DTPicker7
DTPDate(7) = DTPicker8
DTPDate(8) = DTPicker9
DTPDate(9) = DTPicker10
End Sub
Private Sub PayIncreaseComboBox_Change()
Dim DTPicker(9) As String
Dim Dates As Integer
Dates = PayIncreaseComboBox.Value
For Counter = 1 To Dates
DTPDate(Counter).Visible = True
Next
End Sub
Last edited by kfcSmitty; May 17th, 2005 at 01:46 PM.
-
May 17th, 2005, 01:42 PM
#6
Re: Bleh!
You have declared Dim Dates As Integer, but in the loop you're using Date instead of Dates. Date is a VB keyword and returns the current date as a double precision floating point. Just change your loop to For Counter = 1 To Dates.
-
May 17th, 2005, 01:44 PM
#7
Re: Bleh!
Oops, yeah thanks I missed that..I kept getting overflow errors and couldnt figure out why hehe..
Anyways I fixed that and the loop runs and all, but it doesn't display any of the DTPickers...
P.S. is this forum like most others? where I need to have like 50 posts before my rep points are worth diddily?
-
May 17th, 2005, 01:48 PM
#8
Re: Bleh!
 Originally Posted by kfcSmitty
P.S. is this forum like most others? where I need to have like 50 posts before my rep points are worth diddily?
I think it is 20
Anyway, have you stepped through you code to see what it is actually doing when you run it?
-
May 17th, 2005, 01:52 PM
#9
Re: Bleh!
 Originally Posted by Hack
I think it is 20
Anyway, have you stepped through you code to see what it is actually doing when you run it?
Yeah, I did that, it goes through the loop fine, but its just not displaying the pickers.
ive tried
VB Code:
DTPDate(0) = DTPicker1.Visible = True
'then in the loop
DTPDate(Counter)
'also tried
DTPDate(0) = DTPicker1.Visible
'then in the loop
DTPDate(Counter) = true
'also tried
DTPDate(0) = DTPicker1
'then in the loop
DTPDate(Counter).visible = true
-
May 17th, 2005, 02:01 PM
#10
Re: Bleh!
Have you tried
VB Code:
Dim i As Long
Dim intCounter As Integer
intCounter = 8
For i = 0 to intCounter
dtpDate(i).Visible = True
Next
-
May 17th, 2005, 02:03 PM
#11
Re: Bleh!
Yupp you need to have 20 posts before your rep points are counted.
One of the main differences between VB.Net and VB6 is that in VB6 you can have control arrays, and that controls have a default property (for a DateTime picker it's the Value property). In your code you have declared the DTPDate() array as String. This means that when you do this:DTPicker1 will return the default property value meaning it will return the Date or Time currently in the DTPicker control. Trying to set DTPDate(0) to Visible will of course raise an error since it's a string and doesn't have a Visible property.
What you should do is to replace all the DTPickerX controls with one control array. A control array when all the controls (of the same type) has the same name but different Index property values, you can either set those yourself or to do it a bit easier:
1. Delete all the DTPickers you have on the Form except the first one.
2. Right click on this remaining control and select Copy
3. Right click on an empty space on the Form and select Paste
4. You will now get a question if you want to create a control array, answer Yes.
5. Keep pasting the controls until you have the amount you want.
6. Use code simular to this:
VB Code:
Dates = DTPicker1.UBound
For Counter = 0 To Dates
DTPicker1(Counter).Visible = True
Next
-
May 17th, 2005, 02:04 PM
#12
Re: Bleh!
Yep, gives me the error I listed above.
Stupid errors! Looks like I am going to have to go home and grab my VB 6 book and my access book.
God this would be so much easier in .NET or C, or anything
Thank god work is done in an hour
----------------------------------------------------------------
Andersson that would work if I were using normal vb6. But I am using the vb6 tied into access 
It doesnt prompt me to make an array out of the pickers, nor do I know how to do it without the copy and paste method.
If you know how to do that in the vb supplied with access it seems that would work for this particular problem
Last edited by kfcSmitty; May 17th, 2005 at 02:09 PM.
-
May 17th, 2005, 02:28 PM
#13
Re: Bleh!
OK how about this:
VB Code:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Name Like "DTPicker*" Then
ctl.Visible = True
End If
Next
-
May 17th, 2005, 02:49 PM
#14
Re: Bleh!
well that displays them all..Thats close enough 
Ill figure it out from here! Thanks a million man!
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
|