OberonPlace.com Forums  

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

Thread Tools Search this Thread Display Modes
Old 16-10-2008, 12:33
Posts: n/a
Default Reading text file, one character at a time

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
Old 16-10-2008, 13:24
shelbym's Avatar
shelbym shelbym is offline
Senior Member
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
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.
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
    Close #1
End Sub
Best of luck,

Reply With Quote

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 13: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 12:41
Reading from an Excel and Putting it into Corel all_ashish CorelDRAW/Corel DESIGNER VBA 6 23-04-2007 04:33
Reading Font Properties from selected text in CD9 sherman01 CorelDRAW/Corel DESIGNER VBA 2 24-11-2004 07:59
reading data from file and generate "labels" LxRAE CorelDRAW/Corel DESIGNER VBA 4 23-01-2004 04:05

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

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