OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28-09-2008, 19:47
CWCN
Guest
 
Posts: n/a
Default Write#, Input#

Hi,
I want to save form entries to a text file and then read them back.
I wanted to use Write# and Input# functions.
On QueryClose:
Code:
Write #iFile, Text1.Value, Text2.Value, Checkbox1.Value
On Initialize:
Code:
Input #iFile, Text1.Value, Text2.Value, Checkbox1.Value
Unfortunately, Input# will not let me write directly into a text box. It wants a variable. That's a whole lot of work and error-prone when there are many entries.
I was hoping to simply copy and paste the whole Write# block and change it into Input#.
Is there a good way to do this?

Thanks.
Reply With Quote
  #2  
Old 28-09-2008, 22:50
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 13
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Variable...

You are correct you have to Input into a Variable, not directly to the object itself.

-Shelby
Reply With Quote
  #3  
Old 30-09-2008, 16:20
11jeremy
Guest
 
Posts: n/a
Default Maybe this could help.

I am not familiar with corel forms but I in visual basic you can do an array of textboxes. In visual basic you just copy it and paste and it will ask you if you want to make an array. Just an idea you can can loop through the checkboxes as well if you have them in an array as well. I am using the file system object for io as I am familiar with it.

'This could Write out your TextFile with an unlimited number of fields
for x = 0 to Ubound(Text1)
MyTextOut = MyTextOut & Text(x).value & "*"
next
MyTextOut = MyTextOut & Checkbox1.value
WriteTextFile MyTextOut


'You could Read it back like this
ReadText = ReadAllTextFile("C:\Test.txt")
TF = Split(ReadText, "*", -1, 1)
for x = 0 to Ubound(Text1)
Text1(x).value = TF(x)
next
Checkbox1.value = TF(Ubound(Text1)+1)


Sub WriteTextFile(TextOut)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\Test.txt", ForAppending, True)
f.Write TextOut
f.Close
End Sub
Function ReadAllTextFile(CFile)
'CFile = "C:\Test.txt"
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(CFile, ForReading)
ReadAllTextFile = f.ReadAll
End Function
Reply With Quote
  #4  
Old 30-09-2008, 16:22
11jeremy
Guest
 
Posts: n/a
Default opps

You might want to use this sub instead because it is for writing.

Sub WriteTextFile(TextOut)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\Test.txt", ForWriting, True)
f.Write TextOut
f.Close
End Sub
Reply With Quote
  #5  
Old 01-10-2008, 00:29
CWCN
Guest
 
Posts: n/a
Default This might work

Thanks, 11jeremy.
I will look into it.
Reply With Quote
Reply


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

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Input in diffrent units without switching vindaa CorelDRAW/Corel DESIGNER VBA 3 04-07-2008 02:46
Help with Color Number Input and Fill JudyHNM CorelDRAW/Corel DESIGNER VBA 2 08-11-2007 11:39
How to write a processing macro? enewbold Macros/Add-ons 2 21-11-2006 11:15
WRITE in CorelDRAW 12 Lev CorelDRAW CS 3 13-04-2006 14:08
CD11: Adding input from user form to document ddonnahoe Code Critique 2 09-04-2004 13:43


All times are GMT -5. The time now is 06:21.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com