Code Snippets

  

Visual Basic Source Code


Welcome to Dream.In.Code
Become a VB Expert!

Join 149,625 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,978 people online right now. Registration is fast and FREE... Join Now!





Read & Write to file

Fast way to read and write to/from file.

Submitted By: m2s87
Actions:
Rating:
Views: 6,076

Language: Visual Basic

Last Modified: January 4, 2007
Instructions: data=sisu_s(where_from)
noproblems=sisu_s(where_from,data)

You can test it with code like:
If sisu_v("C:/bling.txt", "The content of this file is in C:/bling.txt") = True Then
MsgBox (sisu_s("C:/bling.txt"))
End If

Snippet


  1. Function sisu_s(nimi$, Optional arv% = 1) As String
  2.     Open nimi$ For Input As #arv
  3.         sisu_s = Input$(LOF(arv), arv)
  4.     Close #arv
  5. End Function
  6.  
  7.  
  8. Function sisu_v(nimi$, sisu$, Optional arv% = 2) As Boolean
  9.     sisu_v = True
  10.    
  11.     Open nimi$ For Output As #arv
  12.         Print #arv, sisu
  13.     Close #arv
  14.    
  15.     Exit Function
  16.  
  17. viga: sisu_v = False
  18. End Function

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.




Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month