VB 6 Question

Discussion in 'Software' started by foogoo, Nov 3, 2004.

  1. foogoo

    foogoo Major "foogoo" Geek

    Ok I started a new EXE project and I wanted to execute some code I used before on Load. So I dbl click the form and paste in my code and run.
    The pasted code does not execute!! It works fine in the program I am cutting it from.. it is pasted in the right spot I believe..
    EX
    Private Sub Form_Load()

    strt:
    On Error GoTo ErrHandler
    CommonDialog1.CancelError = True

    CommonDialog1.Filter = "Comma Separated (*.csv)| *.csv"
    CommonDialog1.FilterIndex = 2
    CommonDialog1.ShowSave
    strNewFile = CommonDialog1.FileName

    Any ideas.....
    Thanks
     
  2. QuickSilver

    QuickSilver Corporal

    Not my strong point but....

    Code:
    On Error GoTo ErrHandler
    what is ErrHandler?
    Is it a built in function or is this line of code possibly trying to reference something that you haven't copied and pasted from your other project?

    Thats what stands out to me...
     
  3. foogoo

    foogoo Major "foogoo" Geek

    I didnt post the whole code just a snippet...
    Private Sub Form_Load()

    strt:
    On Error GoTo ErrHandler
    CommonDialog1.CancelError = True

    CommonDialog1.Filter = "Comma Separated (*.csv)| *.csv"
    CommonDialog1.FilterIndex = 2
    CommonDialog1.ShowSave
    strNewFile = CommonDialog1.FileName

    x = Dir(strNewFile) 'set filename into x

    i = Len(strNewFile) 'set path lenght into i

    For T = 1 To i
    sc = Right(strNewFile, T) 'search character
    If sc = "\" + x Then 'is sc a \?
    nfn = Right(strNewFile, T - 1) 'new file name for compare

    If x = nfn Then GoTo Dupe 'Filenames match? Goto overwrite option
    End If
    Next T
    GoTo flopn


    Dupe: 'Deal with the duplicate file problem
    iAns = MsgBox("Dupe found overwite ?", vbYesNo)
    If iAns = vbNo Then
    GoTo strt 'If overwrite is not an option restart
    End If 'Else open file to use

    flopn:
    Open strNewFile For Output As #1

    ErrHandler:
    Exit Sub
    End

    End Sub
     
  4. QuickSilver

    QuickSilver Corporal

    Are you getting an error message? Why isn't the code compiling?
     
  5. foogoo

    foogoo Major "foogoo" Geek

    no errors the form just loads and the dialog of where to save the file never appears... like the form load is skipped?
     
  6. QuickSilver

    QuickSilver Corporal

    Looking at the code I can't see what the problem is... my advice to you would be to insert some code in there at intervals that you know will cause something visible to happen... the msgBox style pop ups would be ok.
    Especially if you made that the frist thing to happen in the Load Form sub. If it doesn't pop up then you know something is causing that sub not to get invoked. If it does pop up then you can insert more.
    Alternatively if you know how to use the debugger, dust it off and give it a whirl too...
    Sorry man, its been years since I did VB...
     
  7. Wookie

    Wookie Sergeant Major

    did you put the commondialog control on the form?
     
  8. foogoo

    foogoo Major "foogoo" Geek

    wookie got it .. I figured it out on the way to work this morning, duh... in a hurry and forgot the controls!!!! Thanks for the help brainstorming this one.. everyone who replied!!!!

    This was my first question posted and I appreciate all the help offered.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds