Adblock breaks this site

Run command prompt windows from Visual Basic

Discussion in 'Programming General' started by Govind, Oct 31, 2007.

  1. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    Run command prompt windows from Visual Basic

    I discovered this completely all by myself.

    Declaration:
    Code:
    Public Declare Sub system Lib "msvcrt" (ByVal command As String)
    Usage:
    Code:
    system "COMMAND"
    Where COMMAND is the command to run, like PAUSE, etc...

    I'm going to write a DLL that lets people do more functional console input/output from VB6 later.

    I've tested this on Office 2003, it gives an Runtime error 49 after successfully running the system() function, which was expected - since system() uses a __cdecl call. I don't know whether or not this'll work well on VB6. Someone test?
     
  2. rico760

    rico760 Member

    Joined:
    Nov 8, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    7
    Run command prompt windows from Visual Basic

    coolthats awesome
     
  3. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    Run command prompt windows from Visual Basic

    I always thought this was what Shell and ShellExecute was for ...
     
  4. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Run command prompt windows from Visual Basic

    Im running XP SP2, and i get run-time error 49 "bad dll calling convention" (or something along those lines).

    And swan is right the vb6 API for CMD is shellexecute.
     
  5. demonavenger

    demonavenger Forum Addict
    $5 USD Donor

    Joined:
    Feb 25, 2007
    Posts:
    536
    Referrals:
    0
    Sythe Gold:
    0
    Run command prompt windows from Visual Basic

    Yeah its prob easier just to use shell

    Code:
    Shell "Command"
     
  6. Faskist

    Faskist Tuxhead
    Banned

    Joined:
    Apr 25, 2005
    Posts:
    1,869
    Referrals:
    0
    Sythe Gold:
    0
    Run command prompt windows from Visual Basic

    If you're not doing GUI stuff, why use a GUI-oriented language o:

    Betting most of the things you want to do in the shell could be done more easily with C.
     
< Inline ASM example | Need Help? Ask Me >


 
 
Adblock breaks this site