(SOLVED)Bleh!-VBForums
Results 1 to 14 of 14

Thread: (SOLVED)Bleh!

  1. #1

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    Resolved (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:
    1. For Counter = 1 to Date ' date is the # of boxes picked
    2. DTPicker1.visible = true
    3. 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 03:57 PM.

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    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:
    1. For Counter = 0 to 8
    2.     dtpDate(i).Visible = True
    3. Next
    You wouldn't hard code that 8. That would be a variable for how many should have their visible property toggled to True.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    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 02:30 PM.

  4. #4
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Bleh!

    Post the code that was giving you the error as well as how you were using it.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  5. #5

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    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:
    1. Option Compare Database
    2. Dim DTPDate(9) As String
    3. Dim Counter As Integer
    4.  
    5.  
    6. Private Sub Form_Load()
    7. DTPDate(0) = DTPicker1
    8. DTPDate(2) = DTPicker2
    9. DTPDate(2) = DtPicker3
    10. DTPDate(3) = DTPicker4
    11. DTPDate(4) = DTPicker5
    12. DTPDate(5) = DTPicker6
    13. DTPDate(6) = DTPicker7
    14. DTPDate(7) = DTPicker8
    15. DTPDate(8) = DTPicker9
    16. DTPDate(9) = DTPicker10
    17. End Sub
    18.  
    19. Private Sub PayIncreaseComboBox_Change()
    20.     Dim DTPicker(9) As String
    21.     Dim Dates As Integer
    22.     Dates = PayIncreaseComboBox.Value
    23.         For Counter = 1 To Dates
    24.         DTPDate(Counter).Visible = True
    25.         Next
    26. End Sub
    Last edited by kfcSmitty; May 17th, 2005 at 02:46 PM.

  6. #6
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

  7. #7

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    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?

  8. #8
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Bleh!

    Quote 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?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  9. #9

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    Re: Bleh!

    Quote 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:
    1. DTPDate(0) = DTPicker1.Visible = True
    2. 'then in the loop
    3. DTPDate(Counter)
    4.  
    5. 'also tried
    6.  
    7. DTPDate(0) = DTPicker1.Visible
    8. 'then in the loop
    9. DTPDate(Counter) = true
    10.  
    11. 'also tried
    12.  
    13. DTPDate(0) = DTPicker1
    14. 'then in the loop
    15. DTPDate(Counter).visible = true

  10. #10
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Bleh!

    Have you tried
    VB Code:
    1. Dim i As Long
    2. Dim intCounter As Integer
    3.  
    4. intCounter = 8
    5.  
    6. For i = 0 to intCounter
    7.    dtpDate(i).Visible = True
    8. Next
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  11. #11
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:
    VB Code:
    1. DTPDate(0) = DTPicker1
    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:
    1. Dates = DTPicker1.UBound
    2. For Counter = 0 To Dates
    3.     DTPicker1(Counter).Visible = True
    4. Next
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

  12. #12

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    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 03:09 PM.

  13. #13
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Bleh!

    OK how about this:
    VB Code:
    1. Dim ctl As Control
    2.  
    3. For Each ctl In Me.Controls
    4.     If ctl.Name Like "DTPicker*" Then
    5.         ctl.Visible = True
    6.     End If
    7. Next
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

  14. #14

    Thread Starter
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,124

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.