Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

help with vb (noobie)

- - - - -

  • Please log in to reply
8 replies to this topic

#1
De Reszke

De Reszke

    errrrrrrr, I dunno!

  • Member
  • 27 posts
  • Joined 01-January 04
hi, wondering if anybody can help me please

I am completly new to vb6, so any help would be much apprecciated

basically I have wrote several vbscripts that do various things, and i wanted to create a user interface with vb6, just simple command buttons that run the selected script

can somebody help me please?


How to remove advertisement from MSFN

#2
De Reszke

De Reszke

    errrrrrrr, I dunno!

  • Member
  • 27 posts
  • Joined 01-January 04
I currently have:


Private Sub start_Click()
shell ("c:\program files\cv1.vbs")
End Sub


but no luck :)

#3
Datalore

Datalore

    Friend of MSFN

  • Member
  • PipPipPipPipPip
  • 852 posts
  • Joined 05-October 03
Try this:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const conSwNormal = 1

Private Sub start_Click()
ShellExecute hWnd, "open", "C:\Program Files\cv1.vbs", vbNullString, vbNullString, conSwNormal
End Sub
That should work. If for some weird reason it doesn't, mess around with this:
Shell ("start C:\Program Files\cv1.vbs")
I don't know if the inclusion of the word "start" or "run" makes a difference.

#4
De Reszke

De Reszke

    errrrrrrr, I dunno!

  • Member
  • 27 posts
  • Joined 01-January 04
Thankyou very very much, much appreciated

It worked a treat!!! :)

#5
brian

brian

    Junior

  • Member
  • Pip
  • 51 posts
  • Joined 17-December 03
The easiest way I found is

Shell "explorer c:\program files\cv1.vbs"

#6
Tarun

Tarun

    Spectre

  • Super Moderator
  • 3,187 posts
  • Joined 27-January 04
  • OS:Windows 7 x64
  • Country: Country Flag
A snippet of code that checks for the file you're about to launch. It's helpful in those sort of apps, especially if you deploy to end users.

Public Function FileExists(testFile As String) As Boolean
On Error GoTo noExist
    Dim fn As Long
    fn = FreeFile
    Open testFile For Input As #fn
    Close #fn
    FileExists = True
    Exit Function
noExist: FileExists = False
End Function

Now for your button pressing. (Btw. Give items useful three letter prefixes. Command buttons get cmd etc, List boxes get lst, etc etc.)

Dim Path as String
Private Sub cmdCv1_Click()
    Path = LCase$("C:\PROGRAM FILES\CV1.VBS")
    If FileExists(Path) = True Then
        Call Shell(Path)
    Else
        MsgBox "cv1.vbs was not found." & vbCrLf & "Loading aborted.", vbCritical, "Unable to load cv1.vbs."
    End If
End Sub


#7
XtremeMaC

XtremeMaC

    MSFN SuperB

  • Member
  • PipPipPipPipPipPipPipPipPipPip
  • 5,070 posts
  • Joined 13-October 03
  • OS:Windows 7 x64
  • Country: Country Flag
ok www.experts-exchange.com
should help u a lot.. if not this board..



#8
De Reszke

De Reszke

    errrrrrrr, I dunno!

  • Member
  • 27 posts
  • Joined 01-January 04
Thanks very much you guys, you have all been very helpfull


I have now sorted it! :)

#9
Doggie

Doggie

    I'm very inactive :(

  • Patrons
  • 2,676 posts
  • Joined 13-October 02
best place to start with n00bie coding is buy a book, specifically on visual basic.. (6 or .Net) what ever u have.. or library, or many places on the net.. www.pscode.com for samples. snippets or tutorials..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users