473,387 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB6 Msflexgrid to a .dat file

Hello everybody.

As a new member to vb6, I need your help to ajust a code that will transfer all grid data to a .dat file.

Expand|Select|Wrap|Line Numbers
  1. Dim MyFreeFile As Integer
  2. Dim icol As Integer
  3. Dim irow As Integer
  4. Dim MyString As String
  5. MyFreeFile = FreeFile
  6. Open "C:\Documents and Settings\All Users\Desktop\ord" For Output As MyFreeFile
  7. For irow = 1 To MSFlexGrid1.Rows - 1    'Start from top to bottom
  8.     For icol = 0 To MSFlexGrid1.Cols - 1    'Start from left to Right
  9.         MyString = MyString & MSFlexGrid1.TextMatrix(irow, icol) & _
  10.             IIf((icol = MSFlexGrid1.Cols - 1), "", ",")     'Add value in mystring for each column in Flexgrid
  11.     Next
  12.     Print #MyFreeFile, MyString  'Print to notepad
  13.     MyString = ""   'Reset MyString
  14. Next
  15.  
  16. Close MyFreeFile
Now, what's missing and i dont now how to do it is:

msflexgrid exemple:
Column 1 line 1 of Grid = "H"
Column 2 line 1 of Grid = "A"
Column 3 line 1 of Grid = "HOST"
Column 4 line 1 of Grid = "08989" etc.

Position in the .dat file:
Column 1 line 1 of Grid = Position 1
Column 2 line 1 of Grid = Position 2
Column 3 line 1 of Grid = Position 3
Column 4 line 1 of Grid = Position 9.

At the end, the result would be
"HAHOST 08989"


How can i do this please?

Thanks again
Aug 28 '09 #1
9 4075
debasisdas
8,127 Expert 4TB
you want to write to which fie (location ) ?

What is the error message with your code ?
Aug 28 '09 #2
Actually, i don't have any error. But i have a txt file on my desktop and it transfer the msflexgrid data in that file.

At this moment, it transfer like that:
H,A,HOST,8989,,,200908280700,200908281200,20090828 0700,200908281200,03,,,,,,COL,,,,,,,M,,,,,,,,,,,,, ,,,P,,M03004005300,53.64,380.00,19,,,,88,,,,,,
But i want to change for something like this for example:

HAHOST 8989 200908280700 200908281200 200908280700 200908281200 03 COL M P M03004005300 53.64 380.00 19 88
Some thing that look like that.
Aug 28 '09 #3
debasisdas
8,127 Expert 4TB
remove the , from your code
Aug 29 '09 #4
it's done.

Now i need to put each columns from the MSFlexgrid at the good position in the dat file.

msflexgrid exemple:
Column 1 line 1 of Grid = "H"
Column 2 line 1 of Grid = "A"
Column 3 line 1 of Grid = "HOST"
Column 4 line 1 of Grid = "08989" etc.

Position in the .dat file:
Column 1 line 1 of Grid = Position 1
Column 2 line 1 of Grid = Position 2
Column 3 line 1 of Grid = Position 3
Column 4 line 1 of Grid = Position 9.

At the end, the result would be
"HAHOST 08989"
Aug 29 '09 #5
debasisdas
8,127 Expert 4TB
what exactly you mean by good position in the dat file.
Aug 30 '09 #6
msflexgrid exemple:
Column 1 line 1 of Grid = "H"
Column 2 line 1 of Grid = "A"
Column 3 line 1 of Grid = "HOST"
Column 4 line 1 of Grid = "08989" etc.

Position in the .dat file:
Column 1 line 1 of Grid = Position 1 in the txt file
Column 2 line 1 of Grid = Position 2 in the txt file
Column 3 line 1 of Grid = Position 3 in the txt file
Column 4 line 1 of Grid = Position 9 in the txt file

At the end, the result would be:
"HAHOST 08989"
Aug 30 '09 #7
debasisdas
8,127 Expert 4TB
what is the output that you are getting now ?
Aug 30 '09 #8
With the code above, all value are one beside the other value, split by a ","
Aug 30 '09 #9
debasisdas
8,127 Expert 4TB
remove the , and add CHR(13) to the end of string.
Aug 31 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: MouseHart | last post by:
I've written a simple program in VB 6.0 to list all my MP3 files. To show them on the screen I used an MSFlexGrid named TextGrid (which is not associated with any table or text file) in the...
3
by: Stephen Saunders | last post by:
I developed a simple application for a friend to use and it works just fine on my machine, however, when my friend tries to use it, it complains about an MSFlexGrid license. My app does use an...
0
by: Martin K | last post by:
Hello all..thanks for everyone's advice regarding my SHBrowseForFolder API problem, I was able to put together a public class that runs great! But I have another migration headache regarding the...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
1
by: zoneal | last post by:
Hi, I am involved in the process of migrating vb(6.0) application to vb.net. My application contains only vb controls namely MSFLEXGRID. I want to migrate my application to vb.net completely...
1
by: Steven | last post by:
I develop the application which contains MSFlexGrid to display data. When I try to fill the grid with the text data, I want to adjust the column width so that the width is adjusted to the maximum...
0
by: swas | last post by:
Hi, I want to use the MSFlexGrid in Access. For someone who doesn't know VB6 much at all (and just coping with Access...), a couple of questions: 1. Can the MSFlexGrid be bound to an Access form...
5
by: Ishmael | last post by:
Hi Is Been a 3 Yrs Now (I Still trying to do this) Please help me to do this with Visual Basic 6.0 using Msflexgrid Let say you are the Principal . You have 10 educators and 5 class (Grades)...
5
by: krafla | last post by:
I have a similar problem with a program i made with VB 6.0 - the only control I used is MSFlexGrid - the program was developed on an XP machine. and the first time to use it on another machine i got...
4
by: MiziaQ | last post by:
1. How can I add a string in a particular row and column of an msflexgrid ? 2. How can I import data from a .txt data file into an msflexgrid ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.