Shoutbox

create a .txt file through VB - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: create a .txt file through VB (/showthread.php?tid=25448)

create a .txt file through VB by _BassReFLeX_ on 05-18-2004 at 02:36 PM

Hi there.

hmm. Can anyone help me with something in vb ?...

I would like to know how could I make a text (.txt) file... e.g

txttextinside.text -> text.txt

hm... I've read few tutorials about this but still can't find what I'm looking for .. :P

thnx:)


RE: create a .txt file through VB by Stigmata on 05-18-2004 at 02:42 PM

put into a button or something

code:
open "eatme.txt" For append as 1
print #1, text1.text
close 1


if something is not there, vb automaticly creates it :)

edit :
more advance version
code:
Private Sub Command1_Click()
   Open "C:\Text.txt" For Ouput As #1
     Print #1,
Text1.Text
   Close #1
End Sub

RE: create a .txt file through VB by _BassReFLeX_ on 05-18-2004 at 02:45 PM

hell. thank you jw . thanks a lot m8 ;)


RE: create a .txt file through VB by Stigmata on 05-18-2004 at 03:03 PM

thats ok :)


RE: create a .txt file through VB by Mike on 05-18-2004 at 03:08 PM

BassReFlex...
You can try asking your vb questions at http://www.vbforums.com
I dont say that members here at the MsgPlus! forums here dont know vb but i think VBF is a better place to ask your VB questions.
Im there too :)


RE: create a .txt file through VB by Stigmata on 05-18-2004 at 03:11 PM

why? we have good programmers here :P


RE: create a .txt file through VB by _BassReFLeX_ on 05-19-2004 at 11:10 AM

btw... how do i rewrite the same .txt file.. but not OVERWRITE just continue in blank lines .... :o


RE: create a .txt file through VB by Mike on 05-19-2004 at 11:18 AM

You can read the data in the text before appending and then make a temp string and do: TempString = String1 & String2
If you want i can post an example :)

Also if you have time then register at VBF and ask your questions there :)


RE: RE: create a .txt file through VB by Dempsey on 05-19-2004 at 01:40 PM

quote:
Originally posted by _BassReFLeX_
btw... how do i rewrite the same .txt file.. but not OVERWRITE just continue in blank lines .... :o

dim filenum as integer
filenum= freefile

Open "C:\Text.txt" For Append As filenum
Print filenum, Text1.Text
Close filenum

use append if you want to add to the file and output to rewrite it
RE: create a .txt file through VB by matty on 05-19-2004 at 01:46 PM

code:
'This will write to the text file
Open <Path Of File> for Append As #1
Print #1, Text1.Text
Close #1

'This will read the text file
Dim strTextFile As String
Open <Path Of File> for Input as #1
   Do Until EOF(1)
     Input#1,strTextFile
     Text1.Text=Text1.Text & strTextFile & vbnewline
   Loop
Close #1

'This will clear the text file
Open <Path Of File> For Output As #1
Close #1

'OR

Kill <Path Of File>



It is easiest to use the vb Function App.Path & "\Whatever.txt"

That means that the text file you are looking for is in the same place as the exe, its a lot easier then specifing an exact path because what happens if they install the application to another place :)
RE: RE: create a .txt file through VB by Dempsey on 05-19-2004 at 05:14 PM

quote:
Originally posted by TheBlasphemer
Open file as random?

i dont think that will work as if the file number is random it will be different each time, and it is specified a few times.

This is my 200th post :banana: :banana:  thats not many for nearly a year, maybe i should post more :spam:   

:P
RE: create a .txt file through VB by CookieRevised on 05-19-2004 at 06:07 PM

quote:
Originally posted by Dempsey
i dont think that will work as if the file number is random it will be different each time, and it is specified a few times.

This is my 200th post :banana: :banana:  thats not many for nearly a year, maybe i should post more :spam:   

:P
It doesn't have anything todo with the filenumber...
"Open as random" can mean only two things (depening on which language you use):
A) you can read or write randomly in the file. This means your can read or write to line 5, then to line 2, then to line 9, etc...
or B) It means that you can read and write to the same open file...


RE: create a .txt file through VB by _BassReFLeX_ on 05-21-2004 at 10:08 AM

thanks a lot guys. you rock !