?
Solved

How to put each chars of a line of a text file  into an array ?

Posted on 2003-03-06
5
Medium Priority
?
195 Views
Last Modified: 2010-05-01
here is my code:

Set textStreamObject = fso.OpenTextFile("data.tmp", 1, False, 0)
textzone2.Text = textStreamObject.ReadLine
Set textStreamObject = Nothing
Set fso = Nothing
textzone.Text = "TEST PASSED"

it reads the first line of the file data.temp and its shown in textzone2.

Now id like to put all chars of that line into an array. any suggestions ?
0
Comment
Question by:Punker51
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Accepted Solution

by:
navneet77 earned 200 total points
ID: 8085513
Try a loop with and use mid$
an example

Private Sub Command1_Click()
Dim str As String
Dim a() As String
Dim i As Integer
str = "hello"
ReDim a(1 To Len(str))
i = 1
Do While i <= Len(str)
a(i) = Mid$(str, i, 1)
i = i + 1
Loop

End Sub

the array a will contains "h" "e" "l" "l" "o" after this code is run
0
 
LVL 11

Expert Comment

by:supunr
ID: 8085520
why not use a code like this

Private Sub SomeFunc()
     Dim strLine as String

     Open "C:\data.tmp" For Input as #1

     ' Get the first line
     Line Input #1, strLine
     Close #1

     txtTextBox.Text strLine
End Sub

Good Luck
0
 
LVL 1

Expert Comment

by:Bandy
ID: 8085527
Well, First, Why????
Seems like a kind of pointless thing to do.

something like

    Dim myArr() As String
    Dim ptr As Long
    ReDim myArr(1 To Len(textzone2.Text))
    For ptr = 1 To Len(textzone2.Text)
        myArr(ptr) = Mid(textzone2.Text, ptr, 1)
    Next ptr
0
 
LVL 1

Expert Comment

by:Bandy
ID: 8085542
navneet77 You got there first, and good point about Mid$ rather than just Mid
0
 

Author Comment

by:Punker51
ID: 8089213
Exactly what i wanted to know
thx m8
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question