Results 1 to 12 of 12

Thread: Add combobox and DTP at runtime - VB6

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Question Add combobox and DTP at runtime - VB6

    hello everybody,
    how to add combobox and DTPicker at runtime to a form?
    Thanks in advance
    Last edited by VBFnewcomer; May 29th, 2008 at 07:26 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Add combobox and DTP at runtime - VB6

    Here is a sample using command buttons and textboxs.

    The principle is the same.
    Attached Files Attached Files

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Add combobox and DTP at runtime - VB6

    Thanx for the reply.
    but my problem is with DTP
    Code:
    Set DTP = Me.Controls.Add("VB.DTPicker", "DTP1")
    the above line gives me an error "Invalid class string..."

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Add combobox and DTP at runtime - VB6

    That's because it isn't VB.DTPicker.... I think the actual class string is longer than that as it's part of a different library from just VB.... and I believe it's ".DateTimePicker"

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Add combobox and DTP at runtime - VB6

    ".DateTimePicker"
    doesn't work

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Add combobox and DTP at runtime - VB6

    Code:
    Set DTP = Me.Controls.Add("MSCOMCTL2.DTPicker.2", "DTP1")
    it seems to be the above, but there is another problem.
    "MSCOMCTL2.DTpicker.2" cannot be added because it is referenced but not in use by any items in the project. To correct this, uncheck 'remove information about unused ActiveX controls' in the project options
    Code:
    Private Sub Form_Load()
    Set DTP = Me.Controls.Add("MSCOMCTL2.DTPicker.2", "DTP1")
      DTP.Height = 500
      DTP.Width = 500
      DTP.Top = 500
      DTP.CheckBox = True
      DTP.Value = Now
      DTP.Visible = True
    End Sub

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Unhappy Re: Add combobox and DTP at runtime - VB6

    while we are splitting our hairs on DTP, how to set the .Style property of the combo created in runtime MSDN says that .Style allows only design time manipulations and read only during runtime.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Add combobox and DTP at runtime - VB6

    That is true even if you added it at design time.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Question Re: Add combobox and DTP at runtime - VB6

    Quote Originally Posted by Hack
    That is true even if you added it at design time.
    so how do you guys manipulate the combo at runtime

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Add combobox and DTP at runtime - VB6

    I was googling for the combo problem I found this link on the similar issue but I am not able to make anything out of it. Can somebody confirm the issue there is same as mine, if so how do I implement the same (i.e usage)

  11. #11
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Add combobox and DTP at runtime - VB6

    Quote Originally Posted by VBFnewcomer
    I was googling for the combo problem I found this link on the similar issue but I am not able to make anything out of it. Can somebody confirm the issue there is same as mine, if so how do I implement the same (i.e usage)
    I haven't tested the code in that link. But from the looks of it, it's awesome

    If it works then yes you need to do it that way. but remember what the author has to say...

    Of course the drawback there is VB will know nothing
    about it and you'll have to use strictly Api methods with it, plus
    subclassing for all events.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Add combobox and DTP at runtime - VB6

    Thanks Kool
    how do I use it?? Like if I want the combo in a particular style how do I go about it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width