Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: (VB 6.0) Auto-execute via Combo Box Selection  (Read 8262 times)

0 Members and 1 Guest are viewing this topic.

keyven

  • Guest
(VB 6.0) Auto-execute via Combo Box Selection
« on: January 22, 2007, 03:43:58 AM »
Can anyone help me... I need to ensure whenever I select a Combo Box Option, it will run the respective command.

This is for Visual Studio 6.0. Thanks in advance.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: (VB 6.0) Auto-execute via Combo Box Selection
« Reply #1 on: January 22, 2007, 12:06:46 PM »
Try using the shell function:

Code: [Select]
dim rc as integer
rc = shell("notepad.exe")

Note: if it's a batch command, you need to include the command processor in the shell function:

Code: [Select]
dim rc as integer
rc = shell("cmd /c copy fileA fileB")

Happy programming. 8-)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

keyven

  • Guest
Re: (VB 6.0) Auto-execute via Combo Box Selection
« Reply #2 on: January 22, 2007, 06:32:49 PM »
Thank you! But how do i integrate it into my code... i know Combo Box options can be identified by integer as well.

Quote
Private Sub Combo3_Change()

    xlDoc = cbx_DailyRep.Text

    Set xlApp = New Excel.Application

    Set xlBook = xlApp.Workbooks.Open("d:\oss\" & xlDoc & ".xls")
 
    xlApp.Visible = True
    
    Set xlBook = Nothing
    Set xlApp = Nothing

End Sub

In here, how do i encode it so that a specific excel document will open when i choose the option from the combo box? Is it possible or is there something i'm missing out on?

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: (VB 6.0) Auto-execute via Combo Box Selection
« Reply #3 on: January 23, 2007, 05:29:36 AM »
Quote
I need to ensure whenever I select a Combo Box Option, it will run the respective command

Misread read your question to imply an external command. What was I thinking :-?

This should work:

Code: [Select]
Private Sub Combo3_Change()
   xlDoc = cbx_DailyRep.Text
   Set xlApp = New Excel.Application
   Set xlBook = xlApp.Workbooks.Open("d:\oss\" & [highlight]combo3.seltext[/highlight] & ".xls")
   xlApp.Visible = True
   Set xlBook = Nothing
   Set xlApp = Nothing
End Sub

Naturally all the choices in the list need to be Excel workbooks.

 8-)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

keyven

  • Guest
Re: (VB 6.0) Auto-execute via Combo Box Selection
« Reply #4 on: January 29, 2007, 08:40:32 PM »
sry for the tardy reply, but thanks for your help  :D