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 16-10-2008, 13:33
CWCN
Guest
 
Posts: n/a
Default Reading text file, one character at a time

Hi,
In VBA, what is the best way to read a text file, one character at a time?
Can I use the "=" operator to compare the character read with another character? [If strVar = "E" then ...]
In C you can't use the "=" to compare strings.
How does VBA handle the end of line?
Are there any characters between the last text character and EOF?

Thank you.
Reply With Quote
  #2  
Old 16-10-2008, 14:24
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
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 VBA and Strings

Yes you can use the = to compare characters in VBA. Here is a little example for you. It opens the test file, reads each line, and looks for the character.
Code:
Sub ReadMyTextFile()
    Dim sLine As String
    Dim n As Long, c As String

    Open "C:\Temp\myFile.txt" For Input As #1
        While Not EOF(1)
        Line Input #1, sLine
            For n = 1 To Len(sLine)
                c = Mid$(sLine, n, 1)
                If c = "E" Then MsgBox "I found an E!"
            Next n
        Wend
    Close #1
End Sub
Best of luck,

-Shelby
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
Exproting to fixed size with current time as file name vindaa CorelDRAW/Corel DESIGNER VBA 2 18-07-2008 14:26
How to import values from a file, replace text,save file for each value with new name amaart CorelDRAW/Corel DESIGNER VBA 1 28-09-2007 13:41
Reading from an Excel and Putting it into Corel all_ashish CorelDRAW/Corel DESIGNER VBA 6 23-04-2007 05:33
Reading Font Properties from selected text in CD9 sherman01 CorelDRAW/Corel DESIGNER VBA 2 24-11-2004 08:59
reading data from file and generate "labels" LxRAE CorelDRAW/Corel DESIGNER VBA 4 23-01-2004 05:05


All times are GMT -5. The time now is 07:27.


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