Members Login.
 

Please register HERE to be part of our Community
Contest of the Day.
 
Participate and Earn $$$.
Looking to Hire.
 
Earn By Posting
 
Participate in forum and Earn $$$.
  • Referrer Credit - BRL$ 100
  • Positive Rep Cr. - BRL$ 3
  • New Thread Cr.- BRL$ 3
  • Posting Cr. - BRL$ 3
  • Post size Credit
Full List of BRL$ Earnings
Sponsors.
 


VB & Delphi Development and coding discussion related to Visual Basic and Delphi programming

Reply
  #1 (permalink)  
Old 04-11-2008
Link Exchange - Jr. Member
 
Join Date: Apr 2008
Posts: 181
Rep Power: 3
tukyunaaya is on a distinguished road
BRL$: 20.45
Default Load file to TextBox/Save TextBox to file

Code:
Public Function LoadFileToTB(TxtBox As Object, FilePath As _
String, Optional Append As Boolean = False) As Boolean

'PURPOSE: Loads file specified by FilePath into textcontrol
'(e.g., Text Box, Rich Text Box) specified by TxtBox

'If Append = true, then loaded text is appended to existing
' contents else existing contents are overwritten

'Returns: True if Successful, false otherwise

Dim iFile As Integer
Dim s As String

If Dir(FilePath) = "" Then Exit Function

On Error GoTo ErrorHandler:
s = TxtBox.Text

iFile = FreeFile
Open FilePath For Input As #iFile
s = Input(LOF(iFile), #iFile)
If Append Then
TxtBox.Text = TxtBox.Text & s
Else
TxtBox.Text = s
End If

LoadFileToTB = True

ErrorHandler:
If iFile > 0 Then Close #iFile

End Function

Public Function SaveFileFromTB(TxtBox As Object, _
FilePath As String, Optional Append As Boolean = False) _
As Boolean

'PURPOSE: Saves contents of text control (e.g., Text Box,
'Rich Text Box) specified by TxtBox to file specified by FilePath

'If Append = true, then TxtBox's contents are
'appended to existing file contents
'else existing file is overwritten

'Returns: True if Successful, false otherwise

Dim iFile As Integer

iFile = FreeFile
If Append Then
Open FilePath For Append As #iFile
Else
Open FilePath For Output As #iFile
End If

Print #iFile, TxtBox.Text
SaveFileFromTB = True

ErrorHandler:

Close #iFile
End Function
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Function to list file formats inside a ZIP file Rss_Feeds PHP 0 09-30-2007 01:16 AM
How do I load a text file into a javascript variable as a string? brl_admin JavaScript 0 09-05-2007 10:04 PM
Guide:Help you to creat Flash Video much easily. moppet Web Designing 0 07-25-2007 03:42 AM
File Station - free file hosting. 5Gb online storage, 250Mb per file Rss_Feeds Free Web Hosting Offers 1 07-18-2007 04:09 AM
Need help turning a IMAGE upload script into a File uploader Rss_Feeds PHP 0 07-15-2007 07:27 AM


 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91