Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2003, 05:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok, the problem is that here
Text1.Text = Input$(LOF(F), F)
you're passing LOF(F) to the Input function, but LOF is Length Of File so it reads the whole file right there. What you need instead is
Line Input #F, Text1.Text

On other thing, it gets a bit tedious to have to do this for each text box, you could make it easier by using the form's Controls collection. Something like this:
Code:
' code to save all values to the registry
    Dim ctl As Control

    For Each ctl In Me.Controls

        If TypeOf ctl Is TextBox Then

            Call SaveSetting(App.EXEName, "Persist", ctl.Name, ctl.Text)

        End If

    Next

' code to get the values back from the registry
    Dim ctl As Control

    For Each ctl In Me.Controls

        If TypeOf ctl Is TextBox Then

            ctl.Text = GetSetting(App.EXEName, "Persist", ctl.Name, "")

        End If

    Next
You could modify that to save to a text file instead if you want. Also note that 'Me' refers to the form in which the code is placed, if you want you could have this code in a Module or Class and pass in a reference to the form instead.

hth
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI & MDI Child Forms Menu's in VB2005 yulyos Visual Studio 2005 0 September 7th, 2007 09:49 AM
MDI Forms Gustav_Haglund VB How-To 8 December 8th, 2005 07:05 PM
MDI Forms kobystud C# 0 June 7th, 2004 04:14 AM
MDI Forms tim33_909 VB.NET 2002/2003 Basics 1 November 17th, 2003 03:42 PM
MDI Forms? aldwincusi VB How-To 1 September 11th, 2003 04:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.