Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving each row of MsFlexgrid in differned files ???

Status
Not open for further replies.

bledileka

Programmer
Nov 15, 2006
16
hello everyone!
im tryin to make a sales system using only files. I dont know if its useful but for me it looks the easiet way to learn visual basic. i did the invoice using a simple form in which i puted a lot of textboxes. When i save the invoce it saves automaticaly all products, quntities etc. but i think it will be easier if i use msflexgrid. Till now i could add the selected data to rows of flexgrid but i dont know how to save it with apropriate data to each file.
Is there anyway i can do that ? Can anybody help on this ?
f33ce794a1invoice.JPG
 
Explain what you mean by using files?
What type of files do you wish to export to?

RSVP

JaG

yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
files like .txt or anyother.just for storing the information. Each cell will be saved in a file.
 
Sounds to me like you are setting yourself to a really nasty nightmare with the text files for all of your info.

Do some research about data bases – even Access will do just fine - and it is not that hard, and it will do what you want, plus A LOT MORE.

Just my $0.02

---- Andy
 
bledileka,

Andrzejek is right, to save each cell into a file would be programmatic suicide. Finding each of those files when you need them again is going to create a lot of problems, especially when you move the program around computers.

Search this forum for

"ADO Newbie"

you will find some good start material on Database connections and usage.

HTH

JaG


yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
On the Topic of MSdatagrid's , how do can you get the field names into the header row ? . I have got a fixed (Grey) row ready for it , but i cant seam to get the table definations into it ?

How can i call it and insert it into my table .

Thanks in advance.


Chris
 
hi chris !
to add the data in the first row i defined them on form load event like this :

yourmsflexgridename.row=0
yourmsflexgridename.col=1
yourmsflexgrid.text="First Title"

yourmsflexgridename.row=0
yourmsflexgridename.col=2
yourmsflexgrid.text="Second Title"

like this till the number of columns u have.

bye
For adding the data to the flex grid i wrote some lines like :
dim a
for a = 1 to yourmsflexgridname.rows
do
while a < yourmsflexgridname.rows+1
'(actualy while a=flexgridname.rows)
.
.
.

ect ect.
if u want this i can give it to u later coz i dont have my source on this pc.
 
royalcheese,
On grids like MsFlexGrid you can also use the Format string property.
 
50fb041b6b123.JPG

this is the way i did for making a report of the products in the warehouse using files. I named files .lnk :)for the reasons: 1- that when u right click on it u dont see any open with and 2- coz i dont wanna spend time encrypting all the file texts.i dunno if this will be helpful but anyway u can try.


Dim fs2, f2, f12, fc2, s2 'variabla
Set fs2 = CreateObject("Scripting.FileSystemObject") 'leja per te punuar me dokumenta nga sistemi
Set f2 = fs2.GetFolder(adresa & "Hyrjet\Kategorite\" & kategoria) 'ngarkim i listes se furnitoreve
Set fc2 = f2.SubFolders 'rendit nendirektorite e ketij folderi
For Each f12 In fc2 'perseritje e rutines deri ne listimin total
rrjeta.AddItem (f12.Name) 'shto furnitoret ne kolonen e pare

For z = 3 To rrjeta.Rows 'fillim i rregjistrimit te koordinatave per cdo emer ne liste
Do
Loop Until rrjeta.Rows
rrjeta.Row = z - 1 'DIFEKT !!! meqe nuk mund te filloje ne rreshtin nr 1 filloj rregjistrimin nga rreshti 2
rrjeta.Col = 0 'kolona e pare fare (0)
a = rrjeta.Text 'a mer vleren e tekstit ne kete kordinate (2,0)



Next
rrjeta.Col = 1 'shko ne kolonen 1

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\emertimi.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close

rrjeta.Col = 2 'shko ne kolonen 2

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\sasia.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close
peshatot = peshatot + 0 + rrjeta.Text
rrjeta.Col = 3 'shko ne kolonen 3

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\njesia.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close
rrjeta.Col = 9
rrjeta.Text = "Leke"
rrjeta.Col = 4 'shko ne kolonen 4

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\cmimib.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close

rrjeta.Col = 5 'shko ne kolonen 5

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\cmimid.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close

rrjeta.Col = 6 'shko ne kolonen 6

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\sasiahyrje.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close

rrjeta.Col = 7 'shko ne kolonen 7

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\sasiadalje.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close

rrjeta.Col = 8 'shko ne kolonen 8

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\totali.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = ts.readline
ts.Close

rrjeta.Col = 9 'shko ne kolonen 9

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\totali.lnk")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
rrjeta.Text = "Leke"
ts.Close

Next

nrartikuj = rrjeta.Rows - 2
 
WOW! Talking about keeping data in sync in so many text files. Must be a full time job just to make sure they all align properly.

You have A LOT of
Set fs2 = CreateObject("Scripting.FileSystemObject")
Do you have any place where you Set all of them Objects to Nothing?
Set fs2 = Nothing

If all of those emertimi.lnk, sasia.lnk, njesia.lnk files are text files, wouldn’t it be easier to use VB native Open method?

Code:
Dim strTextLine as String

Open adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\[b]emertimi.lnk[/b]" For Input As #1
Do While Not EOF(1)   ' Loop until end of file.
   Line Input #1, strTextLine   ' Read line into variable.
   Insert it into your Grid
Loop
Close #1

Open adresa & "Hyrjet\Kategorite\" & kategoria & "\" & a & "\[b]sasia.lnk[/b]" For Input As #1
Do While Not EOF(1
   Line Input #1, strTextLine 
   Insert it into your Grid
Loop
Close #1

Etc.

You may use FreeFile instead of #1, if you want to.

---- Andy
 
thnx Andy but as i said i did it my way without askin. :)
with ur help now i can do better.

Thnx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top