CS.RIN.RU - Steam Underground Community
http://cs.rin.ru/forum/

Read from a .txt[vb6]:
http://cs.rin.ru/forum/viewtopic.php?f=14&t=9667
Page 1 of 1

Author:  |2eM!x [ Saturday, 15 Jan 2005, 17:48 ]
Post subject:  Read from a .txt[vb6]:

okay guys ive written this:

Private Sub Command1_Click()

   Dim hFile As Long
   Dim sFilename As String

   sFilename = (App.Path & "\demo.txt")
   
  'obtain the next free file handle from the
  'system and and save the text box contents
   hFile = FreeFile
   Open sFilename For Append As #hFile
      Print #hFile, Text1.Text, Text2.Text, Text3.Text
   Close #hFile
   
End Sub

Private Sub Command2_click()
Dim hFile As Long
   Dim sFilename As String
sFilename = (App.Path & "\demo.txt")
   
If vbYes = MsgBox("Are you SURE you want to clear all??", _
                      vbQuestion + vbYesNo, _
                      "Clear all?") Then
 
  'obtain the next free file handle from the
  'system and and save the text box contents
   hFile = FreeFile
   Open sFilename For Output As #hFile
      Print #hFile, " "
   Close #hFile
End If
End Sub
   


now i want it to happen, so that if today is the day they entered, a messagebox will popup and say "Event:<Eventname>,Time,Date"

how can i make it read the text, look for the day/year and then make a message box for it?

thanks lots :wink:

Author:  jarro_2783 [ Sunday, 16 Jan 2005, 15:12 ]
Post subject: 

Can you post a bit more like a screenshot of the form, and actually tell us what you are trying to do.
I know how to do it, I just don't know what exactly to tell you because I don't know what you're trying to do.

Author:  |2eM!x [ Sunday, 16 Jan 2005, 17:04 ]
Post subject: 

make a calander, so the user enters the date/time/event into 3 different textboxs, then they save with the functions above (it works)

but now i want it that if any date in the text is today, that when the program is started it will post a messagbox "Event:" Now, "Event name"

i hope you understand

Author:  jarro_2783 [ Monday, 17 Jan 2005, 15:56 ]
Post subject: 

That is quite difficult to do. But I can tell you the basic code, you'll have to work out the rest.
What you can do is open a file for input, instead of writing to it, it reads from it.
So you put:

open file.txt for input as #1

change the #1 to something else if you already have something open as #1, don't forget to close it when you're finished with it. Type close #1 to close it.

Then what you can do is type:

line input #1, variable

Variable is a variable that you read it into, or it could be an array. The variable has to be a string. Then you could use if statements to compare all the dates etc.

Author:  |2eM!x [ Monday, 17 Jan 2005, 16:08 ]
Post subject: 

thanks, ill try it out

Author:  |2eM!x [ Monday, 17 Jan 2005, 16:40 ]
Post subject: 

okay, got what your saying, not sure if i got it:
Dim now As String
Open file.txt For Input As #1
Line Input #1, Split(now)(0)
If Input #1 = now then
MsgBox ("YOU HAVE A EVENT!"), now
End If
End Sub


but the If Input #1 = now then
is a syntax error, do you have any ideas how i make it look for a file?
example:
If Line Input #1, Split(now)(0) = FOUND then
MsgBox ("YOU HAVE A EVENT!"), split(now)(0)

Author:  Tical [ Tuesday, 18 Jan 2005, 02:31 ]
Post subject: 

Option Explicit
Private Declare Function PathFileExists Lib "shlwapi.dll" _
Alias "PathFileExistsA" ( _
ByVal pszPath As String) As Long

then use it like this:->
If IsFilePath(App.Path & "yourfile.txt") Then msgbox "-> File found!"

Author:  jarro_2783 [ Tuesday, 18 Jan 2005, 13:33 ]
Post subject: 

You would do it like this:

open file.txt for input as #1

for count = 1 to 5
line input #1, array(count)
next count
if array(1) = now then
msgbox("It's now")
end if

You read it into a variable, then you compare what is in the variable.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/