473,379 Members | 1,312 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,379 software developers and data experts.

Loading MSFlexGrid in Form_Load()

63
Hey. I have a problem. I am entering data into various textboxes and writing it to a file. I then reading that data in a MSFlexGrid table. I have no problem with that. The only problem is that when the application is closed, the current state of the table is not saved. How can I do that ?

Here's my code, all under the AddDelivery button:

Private Sub cmdAddDelivery_Click()

Open App.Path & "\deliveries.txt" For Append As #11
Write #11, txtPName.Text, txtPAddress1.Text & ", " & txtPAddress2.Text & ", " & cboPTown.Text, cboPPrefix.Text & " " & txtPTelephone.Text & ", " & cboPMPrefix.Text & " " & txtPMobile.Text, txtDName.Text, txtDAddress1.Text & ", " & txtDAddress2.Text & ", " & cboDTown.Text, cboDPrefix.Text & " " & txtDTelephone.Text & ", " & cboDMPrefix.Text & " " & txtDMobile.Text, txtWeightOfPackage.Text, txtDeliveryPrice.Text, txtPickupDate.Text, txtDeliveryDate.Text

MsgBox "New Delivery has been Added !", vbInformation, "Success!!!"

txtPName.Text = ""
txtPAddress1.Text = ""
txtPAddress2.Text = ""
cboPTown.Text = ""
cboPPrefix.Text = "021"
txtPTelephone.Text = ""
cboPMPrefix.Text = "085"
txtPMobile.Text = ""

txtDName.Text = ""
txtDAddress1.Text = ""
txtDAddress2.Text = ""
cboDTown.Text = ""
cboDPrefix.Text = "021"
txtDTelephone.Text = ""
cboDMPrefix.Text = "085"
txtDMobile.Text = ""
txtWeightOfPackage.Text = ""
txtDeliveryPrice.Text = ""
txtPickupDate.Text = ""
txtDeliveryDate.Text = ""

txtPName.SetFocus

Close #11

Open App.Path & "\deliveries.txt" For Input As #12

Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long

Dim strID As String
Dim strPickupName As String
Dim strPickupAdd As String
Dim strPickupTel As String
Dim strDelName As String
Dim strDelAdd As String
Dim strDelTel As String
Dim strWoP As String
Dim strDelPrice As String
Dim strPriority As String
Dim strPickupDate As String
Dim strDelDate As String

Dim counter As Integer

counter = 1

Do Until EOF(12)
Input #12, strPickupName, strPickupAdd, strPickupTel, strDelName, strDelAdd, strDelTel, strWoP, strDelPrice, strPickupDate, strDelDate
MSFlexGrid1.TextMatrix(counter, 0) = ""
MSFlexGrid1.TextMatrix(counter, 1) = strPickupName
MSFlexGrid1.TextMatrix(counter, 2) = strPickupAdd
MSFlexGrid1.TextMatrix(counter, 3) = strPickupTel
MSFlexGrid1.TextMatrix(counter, 4) = strDelName
MSFlexGrid1.TextMatrix(counter, 5) = strDelAdd
MSFlexGrid1.TextMatrix(counter, 6) = strDelTel
MSFlexGrid1.TextMatrix(counter, 7) = strWoP
MSFlexGrid1.TextMatrix(counter, 8) = strDelPrice
MSFlexGrid1.TextMatrix(counter, 9) = strPickupDate
MSFlexGrid1.TextMatrix(counter, 10) = strDelDate
counter = counter + 1
Loop

MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For lngRow = MSFlexGrid1.Rows - 2 To MSFlexGrid1.Row Step -1
For lngCol = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.TextMatrix(lngRow + 1, lngCol) = MSFlexGrid1.TextMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.Row Then
MSFlexGrid1.TextMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next

Close #12

End Sub

thanks
Feb 21 '08 #1
4 2189
jamesd0142
469 256MB
Under the froms closing event
[write code]
or
[call function]
to save
Feb 21 '08 #2
mafaisal
142 100+
Hello

Try This

In VB6

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  2.   Call cmdAddDelivery_Click()
  3. End Sub
  4.  
  5. or
  6.  
  7. Private Sub Form_Unload(Cancel As Integer)
  8.   Call cmdAddDelivery_Click()
  9. End Sub
  10.  
  11.  
in .Net Call function Form Close Event

Faisal
Feb 21 '08 #3
MiziaQ
63
I did that and I get an error 381, subscript out of range,
it's highlighting MSFlexGrid1.TextMatrix(counter, 0) = ""
Feb 21 '08 #4
mafaisal
142 100+
Hello

Here I think U donot Increment ur Rows of flexgrid,
So the error subscript out of range is come
Check the code using break pont and also hw many rows set ur grid and its no is increment in loop

Faisal

I did that and I get an error 381, subscript out of range,
it's highlighting MSFlexGrid1.TextMatrix(counter, 0) = ""
Feb 22 '08 #5

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

Similar topics

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...
13
by: PW | last post by:
Hi, This is bizarre. I've check and rechecked the spelling, cut and paste the name of the form (when trying to rename the form) and the control yet I still get a parameter prompt when the form...
5
by: sansann | last post by:
Hello there! i need help on loading data from my Access database query table name combine into my MSFlexgrid select by batchno category. when i runn below coding the error said "Selected collating...
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)...
0
by: wankhusairi | last post by:
hallo sir .. i am still new on using vb and i have tried to load an excel using a visual basic interface.. but if i wanted to plot my excel data what should i do.. must i cahnge my program on loading...
0
by: MiziaQ | last post by:
Hey, I'm using the following code to filter an msflexgrid to only display rows with the entry "East Cork" in the 8th column. The table has many more entries, so, when I run the application, many...
2
by: JuAn2226 | last post by:
hi,I got few question here. Hope some one can me. plz help me i running out of time 1. how to make my msflexgrid to display data for every 5 min(especially the number car and average speed. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.