Hi Brittany,

You have 2 options: write to a simple text file or write to a database.

Writing to a text file is simple.

'-----------------------------------------
' Gambas class file
PUBLIC hFile AS File

PUBLIC SUB form_Activate()
  'create the file if it does not exist, otherwise just open it 
  IF Exist(Application.path & "/file.txt") THEN  
    hFile = OPEN Application.path & "/file.txt" FOR WRITE APPEND 
  ELSE 
    hFile = OPEN Application.path & "/file.txt" FOR WRITE CREATE
  ENDIF 
  TextBox1.SetFocus
END

PUBLIC SUB btnExit_Click()
  hFile.Close
  FMain.Close
END

PUBLIC SUB btnWrite_Click()
  'write the 2 textboxes to the File
  PRINT #hFile, TextBox1.text & "," & TextBox2.text
  'clear the textboxes and put the cursor back in the first
  TextBox1.text = ""
  TextBox2.text = ""
  TextBox1.SetFocus
END
'------------------------------

You can check the file (file.txt) by loading it in any text processor.
Because of the 'application.path', you will find it in the same directory as
your program.

Writing to a database is more flexible and a little more difficult. You can
create a simple SQLite database from Gambas though it is probably easier
using a very adequate add-on to Firefox (click Tools,add-ons and search
sqlite). You can see how to open and write to sqlite with a small tutorial
at www.kalaharix.wordpress.com.

rgds
-- 
View this message in context: 
http://www.nabble.com/How-to-write-to-a-file---tp19544483p19547768.html
Sent from the gambas-user mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to