Home / Software / Computer programming / (VB 6.0) Auto-execute via Combo Box Selection
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: (VB 6.0) Auto-execute via Combo Box Selection  (Read 2476 times)
keyven
Guest
« 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.
IP logged
Sidewinder
Guru



Thanked: 97
Posts: 4,341

Experience: Familiar
OS: Windows 7

« 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-)
IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
keyven
Guest
« 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?
IP logged
Sidewinder
Guru



Thanked: 97
Posts: 4,341

Experience: Familiar
OS: Windows 7

« 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-)
IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
keyven
Guest
« Reply #4 on: January 29, 2007, 08:40:32 PM »

sry for the tardy reply, but thanks for your help  :D
IP logged
Pages: [1] - (Top) Print 
Home / Software / Computer programming / (VB 6.0) Auto-execute via Combo Box Selection « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.09 seconds with 20 queries.