AllExperts > Experts 
Search      

Visual Basic

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Visual Basic Answers
Question Library

Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Ravindra
Expertise
visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel. Optional: 1)a large number of people want me to do work which takes some time and effort. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a donation of 1$. 4) you can visit my website http://ravindra.coolpage.biz (under constrn)

Experience

Past/Present clients
project work for a Norway company, and a Canadian company completed. Freelance Project work and Teaching
teaching vb

 
   

You are here:  Experts > Computing/Technology > Basic > Visual Basic > MSFlexGrid Data ,put it in .txt

Topic: Visual Basic



Expert: Ravindra
Date: 6/23/2008
Subject: MSFlexGrid Data ,put it in .txt

Question
read this type of data from .txt and put it in MSFlexGrid,

Coke     4500 1 2 3 4 5
Minerals 4200 5 4 6 3 1

And Also
read data from MSFlexGrid and put it in .txt file in VB6.0?
Data is
Coke 4500 1 2 3 4 5
Minerals 4200 5 4 6 3 1

Answer
my system was down and restored now. because of the backlog of unanswered questions, i'll be able to reply you in a couple of days

this is code to read text file for data separated by tab
Name of flexgrid is G
Option Explicit
Dim elli(6) As Integer, enu(6) As String, i As Integer

Private Sub Command1_Click()
Dim i As Integer, linecount As Integer, entry As String
Dim rowval As Integer, colVal As Integer
i = 1
Open "C:\Ravi.txt" For Input As #1
linecount = 1
  Do While Not EOF(1)
     Line Input #1, entry
     G.Rows = G.Rows + 1
'here you will get the string of one line. depending upon whether you have space or , separating the values in one line, you can split up the values using instr function
' G.TextMatrix(i, 0) = entry
 Split (entry)
 For colVal = 0 To 6
 G.TextMatrix(rowval + 1, colVal) = enu(colVal)
 Next
 ' you need to write code to paste values to each column of a single row
linecount = linecount + 1
  i = i + 1
 rowval = rowval + 1
  Loop
Close #1

End Sub
Private Function Split(olage As String)
For i = 0 To 5
elli(i) = InStr(1, olage, vbTab)
enu(i) = Mid(olage, 1, elli(i) - 1)
olage = Right(olage, (Len(olage) - elli(i)))
Next
elli(6) = InStr(1, olage, "")
enu(6) = Mid(olage, 1, elli(6))
olage = Right(olage, (Len(olage) - elli(6)))

End Function


similarly to input to text file use
'YOU NEED TO ALTER THE CODE SUITABLY. THIS IS JUST A GUIDE
Private Sub Command1_Click()
Open "C:\Rtest1.txt" For Output As #2 ' WRITE TO FILE
'here you need to construct a loop to read the text from grid
Print #2, grid.Textmatrix(ROWVAL, colval)

Close #2
End Sub


similarly

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.