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. - Dim MyFreeFile As Integer
-
Dim icol As Integer
-
Dim irow As Integer
-
Dim MyString As String
-
MyFreeFile = FreeFile
-
Open "C:\Documents and Settings\All Users\Desktop\ord" For Output As MyFreeFile
-
For irow = 1 To MSFlexGrid1.Rows - 1 'Start from top to bottom
-
For icol = 0 To MSFlexGrid1.Cols - 1 'Start from left to Right
-
MyString = MyString & MSFlexGrid1.TextMatrix(irow, icol) & _
-
IIf((icol = MSFlexGrid1.Cols - 1), "", ",") 'Add value in mystring for each column in Flexgrid
-
Next
-
Print #MyFreeFile, MyString 'Print to notepad
-
MyString = "" 'Reset MyString
-
Next
-
-
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
9 4075
you want to write to which fie (location ) ?
What is the error message with your code ?
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.
remove the , from your code
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"
what exactly you mean by 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 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"
what is the output that you are getting now ?
With the code above, all value are one beside the other value, split by a ","
remove the , and add CHR(13) to the end of string.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
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 ?
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
| |