5 Replies - 3012 Views - Last Post: 28 January 2012 - 06:32 PM Rate Topic: -----

#1 TheCaleb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-January 12

HELP! Save input from text boxes to a txt file in .VBS

Posted 26 January 2012 - 06:04 PM

Alright I am creating program, so far I have an awesome design already mocked up. I have two input boxes so when they click Button1 it will save the input info to a text file. I also want the text file to be on the desktop or maybe a network drive if that's possible? Please help! I have been looking nonstop for the past 5 days, and nothing! thanks
Is This A Good Question/Topic? 0
  • +

Replies To: HELP! Save input from text boxes to a txt file in .VBS

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: HELP! Save input from text boxes to a txt file in .VBS

Posted 27 January 2012 - 01:11 AM

Try spending another 2 minutes and have a look in the VB Tutorials to the right of your post and you will find examples on how to do it.
Was This Post Helpful? 0
  • +
  • -

#3 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 268
  • Joined: 21-May 09

Re: HELP! Save input from text boxes to a txt file in .VBS

Posted 27 January 2012 - 04:59 AM

also when you save or open a file a good advice is to not use a hardwired path for it.
while desktop may not make problems since as far as i know all computers with windows have the same path for it, a netwok drive if unaviable or on different address/path will most likely crash your program or to the very least it could continue to run but the file wont be saved.
look for Microsoft Common Dialog Control 6.0(SP4), this is ActiveX control (file type .oxc) that show the dialogs of opening and saving files as well as printing dialog, font, color and help.
the dialog however wont actually save the file, with tutorial that you'll here you'll know how to handle files and write code for saving/opening them.
the dialog is just for getting the wanted file path
Was This Post Helpful? 0
  • +
  • -

#4 TheCaleb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-January 12

Re: HELP! Save input from text boxes to a txt file in .VBS

Posted 27 January 2012 - 05:00 PM

View PostNeku, on 27 January 2012 - 04:59 AM, said:

also when you save or open a file a good advice is to not use a hardwired path for it.
while desktop may not make problems since as far as i know all computers with windows have the same path for it, a netwok drive if unaviable or on different address/path will most likely crash your program or to the very least it could continue to run but the file wont be saved.
look for Microsoft Common Dialog Control 6.0(SP4), this is ActiveX control (file type .oxc) that show the dialogs of opening and saving files as well as printing dialog, font, color and help.
the dialog however wont actually save the file, with tutorial that you'll here you'll know how to handle files and write code for saving/opening them.
the dialog is just for getting the wanted file path


Thank you for replying. I have this script that works fine on my computer but now instead of saving it to the "C:\" I want to save it to a Network drive "U:\" every time I try running this I get different error messages on "Cannot find path" "Doesn't have Access to this path" etc.

Imports System.IO

Public Class Form1
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click



        Using W As New System.IO.StreamWriter(Path:="U:/test.txt")
            W.Write(Mail.Text + Environment.NewLine + Pass.Text)
            W.WriteLine("")
            W.Close()
        End Using
        
        Exit Sub

    End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#5 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 268
  • Joined: 21-May 09

Re: HELP! Save input from text boxes to a txt file in .VBS

Posted 28 January 2012 - 06:53 AM

hhmm... this code look kinda like .NET ... well you should try putting this \ insted of this after the : in line 9 and after folders if you use them.
like this Path="U:\test.txt"
another thing you should take into account is if the drive you want is aviable or not and if its read/write only as well if it have enough memory.
all of these could trigger problems that can crash your program.
you should add also error trapping.
Was This Post Helpful? 0
  • +
  • -

#6 TheCaleb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-January 12

Re: HELP! Save input from text boxes to a txt file in .VBS

Posted 28 January 2012 - 06:32 PM

Thank you Neku! I did just what you said, I put the \ instead of a /.... That was a foolish mistake but it had a major effect. I also made sure that my User Account had the permission to the U:\ Drive.
Thanks alot for everyone who posted :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1