Adblock breaks this site

VB6: Can someone help me with code?

Discussion in 'Programming General' started by Cymru, Oct 21, 2008.

  1. Cymru

    Cymru Apprentice
    Banned

    Joined:
    Jan 22, 2007
    Posts:
    693
    Referrals:
    0
    Sythe Gold:
    0
    VB6: Can someone help me with code?

    I'm trying to get a simple code working. This is what I have up to now. Oh and I use C# and VB.NET so I hate VB6 and can never get it to work...

    Private Sub Form_Click()
    Dim Start As Label
    Start:
    If Dir("C:\notepad.txt") Then
    Shell ("C:\notepad.txt")
    Else: Form1.Caption = "failzorg"
    End If
    End Sub

    Can someone tell me what is wrong, and give me a working script?

    (this gives an error: type mismatch, but I also get other errors all the time).
    It's like 7 lines of code, so can someone just fix it please?

    THANKS
     
  2. jdsfighter

    jdsfighter Forum Addict
    Visual Basic Programmers

    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0
    VB6: Can someone help me with code?

    This is closer to what you want, but you can not shell a txt file.
    Code:
    Private Sub Form_Click()
        If Dir("C:\notepad.txt") <> "" Then
            Shell ("C:\notepad.txt")
        Else
            Form1.Caption = "failzorg"
        End If
    End Sub
     
  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
    VB6: Can someone help me with code?

    Precisely. You cannot shell a textfile, as a textfile isn't an executable program.

    Try
    Code:
     Shell "notepad C:\notepad.txt"
    Though I haven't used VB6 in a while.
     
  4. Nullware

    Nullware Guru

    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0
    VB6: Can someone help me with code?

    That works in the command prompt so it should do the same when you call it from VB6..
     
  5. Cymru

    Cymru Apprentice
    Banned

    Joined:
    Jan 22, 2007
    Posts:
    693
    Referrals:
    0
    Sythe Gold:
    0
    VB6: Can someone help me with code?

    Thanks a lot. No wonder no matter what I did nothing worked... Thanks everyone.
     
< So, I wanna start Java.... | Hiring a programmer( Details Inside) >


 
 
Adblock breaks this site