Re: [RESOLVED] How to Save classes to binary file vb6
Ok I did a bit of progress today again I was not working this morning
New Update Changes
-Delete button (hopefully got all the deleting bugs)
-Phone list saves/loads (can now modify name or number)
-Task list DOES NOT SAVE/LOAD YET (can only change Result column)
-Retouch of the Notes
-Fixed height of Phone Grid
-Fixed couple bugs found on the way with the new/add/delete/save/load buttons
Let me know what other bugs or things you don't like or want to change
Re: [RESOLVED] How to Save classes to binary file vb6
Thanks for adding that, have you tried to enter data in the phone or task grids neither can be typed into.
Both columns in the phone grid are editable the last column in the task grid
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
Yes it works you need to hit enter to save the text or escape to not save (or simply click on any other control)
Have you tried my update4 project?
It looks to me that both columns on the phone grid are not editable only the last column. Homeowner may want to Names or material supplier in the first column
Can the Phones and Tasks grids be part of a udt ?
eg:
module level variable: Private mstrPhoneNumbersClip As String
Sub SetPhoneClip()
With FlxGrd(0)'phone grid
.Row = 1
.Col = 0
.ColSel = .Cols - 1
.RowSel = .Rows - 1
mstrPhoneNumbersClip = .Clip'save mstrPhoneNumbersClip to file
.Row = 0
.Col = 0
End With
End Sub
Get the data back from saved udt:
Sub GetPhoneClip() 'Fill grid with the phones saved data
With FlxGrd(0)'phone grid
.Row = 1
.Col = 0
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.Clip = mstrPhoneNumbersClip
.Row = 0
.Col = 0
End With
End Sub
still cannot enter data to the FlxGrd(0)'phone grid
or
FlxGrd(1)'Tasks grid, but i can fix this
I do appreciate your help, you have done above and beyond what I needed. if i could get the phones/tasks grids to part of the udt i could finish
Last edited by isnoend07; Sep 5th, 2014 at 04:15 PM.
Reason: correction
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
The phones are part of the UDT.
I haven't done the load/saving of the tasks yet (which won't take long when I work on it).
I am able to load/save phones or names (of phone #) trying to figure out why it doesnt work for you?
Edit:
Noticed that Task_UDT is not created yet, I started it in my new update coming soon (by the end of the day)
Last edited by Max187Boucher; Sep 5th, 2014 at 05:17 PM.
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
It requires a double click on a single cell to activate the txtEdit
Code:
Private Sub FlxGrd_DblClick(Index As Integer)
Dim PhoneContact() As String
Select Case Index
Case 0
GridClicked = Index
GridSelCol = FlxGrd(Index).MouseCol
GridSelRow = FlxGrd(Index).MouseRow
With FlxGrd(Index)
If GridSelCol = 0 Then txtEdit.Left = .Left + 15 _
Else txtEdit.Left = .Left + 15 + .ColWidth(0)
txtEdit.Visible = True
txtEdit.Top = .Top + (.RowHeight(.RowSel - 1) * .RowSel - 1) + 15
txtEdit.Width = .ColWidth(IIf(GridSelCol = 0, 0, 1)) - IIf(GridSelCol = 0, 15, 30)
txtEdit.Height = .RowHeight(1) - 15
txtEdit.Text = .TextMatrix(GridSelRow, GridSelCol)
txtEdit.SetFocus
End With
An easy fix for you would be changing DblClick
Code:
Private Sub FlxGrd_DblClick(Index As Integer)
To Click
Code:
Private Sub FlxGrd_Click(Index As Integer)
I'm not sure if you are using my latest update but it works perfect for me so it should for you.
Yes I am using update4
Cannot determine why it does not work for me.The textbox shows and accepts typed text, but it is not entered into the grids when leaving either to anther row or another control
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
I made it like that, to accept text you need to click enter, when clicking ESC it won't save, and if you leave (lost focus) it does not save, I can easily change so it saves but what if you don't want to change the number you usually would click on another control or click ESC.
You are telling me you want it to change (accept text) if you leave control? Instead of only using enter to validate the text, you would also want it to validate when leaving the control by click on another control?
Edit:
Ok this will be in update5... let me know if you like DoubleClick or SingleClick better (to activate txtEdit)
Code:
Private Sub txtEdit_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyReturn, vbKeyEscape
With FlxGrd(GridClicked)
If KeyAscii = vbKeyReturn Then .TextMatrix(GridSelRow, GridSelCol) = txtEdit.Text _
Else txtEdit.Text = vbNullString
End With
txtEdit.Visible = False
End Select
End Sub
Private Sub txtEdit_LostFocus()
FlxGrd(GridClicked).TextMatrix(GridSelRow, GridSelCol) = txtEdit.Text
txtEdit.Visible = False
GridSelCol = 0
GridSelRow = 0
GridClicked = 0
End Sub
In Red is what makes it behave like you want so just update these two subs. Let me know if this is what you want. The more you tell me the more we'll be able to work it out so it's exactly how you want it to behave
Last edited by Max187Boucher; Sep 5th, 2014 at 06:41 PM.
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
I made it like that, to accept text you need to click enter, when clicking ESC it won't save, and if you leave (lost focus) it does not save, I can easily change so it saves but what if you don't want to change the number you usually would click on another control or click ESC.
You are telling me you want it to change (accept text) if you leave control? Instead of only using enter to validate the text, you would also want it to validate when leaving the control by click on another control?
Yes i would rather have the text entered even if it looses focus. I will just make it dirty and prompt the user for saving changes if they close the form.
Ran into an issue
Was adding records and on the form load they were each added to gridmain i discovered that each time a bid was saved the same item
was added again I think this function needs modification"
Private Function Add_Company()
If the company is already in RoofCompany then update the record
maybe pass the name to the function and maybe
Private Function Add_Company(Optional Delete as boolean) to remove a record
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by isnoend07
Yes i would rather have the text entered even if it looses focus. I will just make it dirty and prompt the user for saving changes if they close the form.
Ran into an issue
Was adding records and on the form load they were each added to gridmain i discovered that each time a bid was saved the same item
was added again I think this function needs modification"
Private Function Add_Company()
If the company is already in RoofCompany then update the record
maybe pass the name to the function and maybe
Private Function Add_Company(Optional Delete as boolean) to remove a record
Ok so we are on the same page, all what you wrote here means...
If company exists simply update it and don't add another entry to file or UDT?
Was there something else you tried to say or that's all you were asking?
Edit:
Would you like a search option?
Add_Company and Delete_Company are two different functions in the program.
Last edited by Max187Boucher; Sep 5th, 2014 at 06:58 PM.
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
Ok so we are on the same page, all what you wrote here means...
If company exists simply update it and don't add another entry to file or UDT?
Was there something else you tried to say or that's all you were asking?
Edit:
Would you like a search option?
Add_Company and Delete_Company are two different functions in the program.
Sorry didn't see the Delete_Company, been coding an earlier version of your code
My plan is to load records to gridMain on the form load from a file. Clicking a company name in gridMain fills the textboxs. phones and Tasks with details. the user can then make additions-changes if desired, if they do they will be prompted and to save the changes
I don't need a search after giving hundreds if not thousands of roof bids it is rare for a homeowner to get more then 5 bids
I have made a change to the file name being saved to:
gMypath = App.path' will be set in Sub Main to typical path C:\Users\Public\Documents\RoofCalculator\AppFolder
Dim MyFile As String
MyFile = gMyPath & "\" & RoofBidder.txtLname & " " & RoofBidder.txtAddress & "RoofBids.dat"
RoofBidder is the main form in the project where the homeowner can enter his name-address and it will do roof calculations the owner enters it will be saved to a different file
Do you want the form ?
Last edited by isnoend07; Sep 5th, 2014 at 07:45 PM.
Reason: more to add
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Everything you are saying in your last post (except the main form) works as expected.
When you "dblclick" on the flxgrd(2) which is originally gridmain from your project it loads their info into the textboxes and when you made the changes you simply click save (in the menu), I can change it so it asks you to save changes when clicking another company if you want. But those things are easy to add, I wanted to get the hard part done
let's finish this form (the roofbidder/form1 form) completely and i will start working on adding your main form later when everything works as expected
I didn't get what you need in the last post.
When you save the company and load them back and click on a company in the flexgrid it does fill the phone numbers and textboxes.
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
Everything you are saying in your last post (except the main form) works as expected.
When you "dblclick" on the flxgrd(2) which is originally gridmain from your project it loads their info into the textboxes and when you made the changes you simply click save (in the menu), I can change it so it asks you to save changes when clicking another company if you want. But those things are easy to add, I wanted to get the hard part done
let's finish this form (the roofbidder/form1 form) completely and i will start working on adding your main form later when everything works as expected
I didn't get what you need in the last post.
When you save the company and load them back and click on a company in the flexgrid it does fill the phone numbers and textboxes.
Ok, you are right prompting for changes is minor and i can do that
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
sorry for the wait here is update5
-Task save/load (as expected)
-Add Button (if it finds the same company in the udt then it simply updates and savetofile)
-Single Click to show information or edit grids (phone/task)
-Moved the open button code to it's own function OpenFromFile (easy to modify)
So now with all the functions required you should be good to start modifying.
Please let me know what else to modify that you do not like, or perhaps would like to add.
Functions are
Populate_Grid 'for flxgrd(2) which is the main grid
Clear_All 'clear all fields, grids (Phone/Task)
OpenFromFile 'opens and loads all the roof company into UDT
SaveToFile 'saves all udt and information to file
Add_Company 'adds new company to UDT
Delete_Company 'removes the company from the udt
Check_Company 'checks to see if company exist if so it returns true (used to update instead of adding new company to UDT)
Last edited by Max187Boucher; Sep 5th, 2014 at 10:46 PM.
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
sorry for the wait here is update5
-Task save/load (as expected)
-Add Button (if it finds the same company in the udt then it simply updates and savetofile)
-Single Click to show information or edit grids (phone/task)
-Moved the open button code to it's own function OpenFromFile (easy to modify)
So now with all the functions required you should be good to start modifying.
Please let me know what else to modify that you do not like, or perhaps would like to add.
Functions are
Populate_Grid 'for flxgrd(2) which is the main grid
Clear_All 'clear all fields, grids (Phone/Task)
OpenFromFile 'opens and loads all the roof company into UDT
SaveToFile 'saves all udt and information to file
Add_Company 'adds new company to UDT
Delete_Company 'removes the company from the udt
Check_Company 'checks to see if company exist if so it returns true (used to update instead of adding new company to UDT)
I tried to save but got an error File not found, so i put a On Error Resume Next but no file is created. There is no need for the add Button the save should add it to the grid and save it to a file
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by isnoend07
I tried to save but got an error File not found, so i put a On Error Resume Next but no file is created. There is no need for the add Button the save should add it to the grid and save it to a file
Think i found the problem on saving opening from file
this part was missing: FF = FreeFile
So FF had no value
Private Function SaveToFile()
Dim FF As Integer
FF = FreeFile 'added
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Open file....
Code:
Private Function OpenFromFile()
Dim FF As Integer
FF = FreeFile
Open "C:\RoofCompany\roof.dat" For Binary As #FF
Get #FF, , ArrayDim
ReDim RoofCompany(ArrayDim)
Get #FF, , RoofCompanyTotal
Get #FF, , RoofCompany
Close #FF
End Function
Wondering if your losing bytes when downloading the project?
Maybe you modify the location "C:\RoofCompany\roof.dat" and your putting it into an invalid (not created) folder? How is everything else? You want to remove the add button? Simply leave the save button?
Edit:
I can always add a folder check first and a error handler, but if you program it correctly, creating the folder when program is installed there should be no problem, tell me the location and I will add it in the form_load, and I'll put a check folder function so you stop getting error on the save/open functions.
I removed Add and moved the buttons to the menu, here is what it looks like, let me know if this is better.
Last edited by Max187Boucher; Sep 6th, 2014 at 11:30 AM.
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
Sometimes I wonder where you get all those errors, are you modifying it? Everything is there... have a look
Code:
Private Function SaveToFile()
Dim FF As Integer
If CurrentCompany > -1 Then
With RoofCompany(CurrentCompany)
.Address = txtInfo(Info.Address).Text
.Bid2Amount = txtInfo(Info.Bid2Amount).Text
.Bid2Material = txtInfo(Info.Bid2Material).Text
.BidAmount = txtInfo(Info.BidAmount).Text
.BidMaterial = txtInfo(Info.BidMaterial).Text
.BusYrs = txtInfo(Info.BusYrs).Text
.City = txtInfo(Info.City).Text
.CompanyName = txtInfo(Info.CompanyName).Text
.Email = txtInfo(Info.Email).Text
.Estimator = txtInfo(Info.Estimator).Text
.sDate = txtInfo(Info.sDate).Text
.Sqs = txtInfo(Info.Sqs).Text
.State = txtInfo(Info.State).Text
.Zip = txtInfo(Info.Zip).Text
.Phones.Cell = FlxGrd(0).TextMatrix(1, 0) & "," & FlxGrd(0).TextMatrix(1, 1)
.Phones.Office = FlxGrd(0).TextMatrix(2, 0) & "," & FlxGrd(0).TextMatrix(2, 1)
.Phones.Emergency = FlxGrd(0).TextMatrix(3, 0) & "," & FlxGrd(0).TextMatrix(3, 1)
.Phones.Fax = FlxGrd(0).TextMatrix(4, 0) & "," & FlxGrd(0).TextMatrix(4, 1)
.Phones.Owner = FlxGrd(0).TextMatrix(5, 0) & "," & FlxGrd(0).TextMatrix(5, 1)
.Tasks.DaysComplete = FlxGrd(1).TextMatrix(1, 1)
.Tasks.ReceivedWork = FlxGrd(1).TextMatrix(2, 1)
.Tasks.ReceivedPLPD = FlxGrd(1).TextMatrix(3, 1)
.Tasks.CompanySubContractor = FlxGrd(1).TextMatrix(4, 1)
.Tasks.ReceivedSubWork = FlxGrd(1).TextMatrix(5, 1)
.Tasks.ReceivedSubPLPD = FlxGrd(1).TextMatrix(6, 1)
.Notes = txtNotes.Text
End With
End If
FF = FreeFile
ArrayDim = UBound(RoofCompany)
Open "C:\RoofCompany\roof.dat" For Binary As #FF
Put #FF, , ArrayDim
Put #FF, , RoofCompanyTotal
Put #FF, , RoofCompany
Close #FF
End Function
I did not add it it was already there
Yes now i see it, i don't know it was not saving/opening, i changed the filename/path
myFile = gMyPath & "\" & RoofBidder.txtLname & " " & RoofBidder.txtAddress & "RoofBids.dat"
'typical path gMyPathC:\Users\Public\Documents\RoofCalcWriter\AppFolder set in sub Main
I added this to the bottom of form load
mOpen_Click 'added so main grid is filled on form load
looks as though i got it with your help
Thanks a lot
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
I'm glad you got it working now, I will be here to help adding your main form, if you want. Let me know.
Thanks
Just doing some little things like;
In case the user clicks open
Private Sub mOpen_Click()
Dim myFile As String 'added
myFile = gMyPath & "\" & RoofBidder.txtLname & " " & RoofBidder.txtAddress & "RoofBids.dat"
If FileExists(myFile) = False Then 'FileExists in module
MsgBox "You have no saved roof bids" 'in case user delets all the bids
'MsgBox "No roof bids have been saved yet"
Exit Sub
End If
OpenFromFile
Populate_Grid
SetGridSize FlxGrd(2)
End Sub
i added the zip in case you see something wrong or needs improvement
Last edited by isnoend07; Sep 6th, 2014 at 07:29 PM.
Reason: delete attachment
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
thanks followed your directions, selected the file then tried to leave,but was prompted to drag files they need a delete button.
i even tried selecting all, same result
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Thanks only tried selecting all after selecting the one i wanted didn't work will try again
After i dragged the selected file an X showed in the top corner hopefully that will delete the file
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Oh no don't go to add files when you click 'Go Advanced' new page load, go to Manage Attachments, then do not click add files just look at the window and look for Attachments, then you will see your file in there just remove it and click done
I reported you, you've been a bad boy, haha no just to remove the attachment, since you can't figure it out
I will look at your project in a little bit, not sure if I will be modify right away but at least have a look
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
Oh no don't go to add files when you click 'Go Advanced' new page load, go to Manage Attachments, then do not click add files just look at the window and look for Attachments, then you will see your file in there just remove it and click done
I reported you, you've been a bad boy, haha no just to remove the attachment, since you can't figure it out
I will look at your project in a little bit, not sure if I will be modify right away but at least have a look
Followed your instructions clicked manage attachment the exact same window opens as add attachments
I select it,but don't see any way to delete
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
Originally Posted by Max187Boucher
Yep, you got it ... ok I will post back whenever I do some work, in the mean time you can test the project for bugs or issues.
hate to bug you but somehow during testing, i have ended up with a blank row
can you modify this to check for a blank row FlxGrd(2)
Private Function Populate_Grid()
Dim i As Integer
Dim j As Integer
FlxGrd(2).Rows = RoofCompanyTotal + 1
For i = 0 To RoofCompanyTotal - 1
With RoofCompany(i)
For j = 0 To FlxGrd(2).Cols - 1
FlxGrd(2).TextMatrix(i + 1, j) = vbNullString
Next j
FlxGrd(2).TextMatrix(i + 1, Recap.CompanyName) = .CompanyName
FlxGrd(2).TextMatrix(i + 1, Recap.Estimator) = .Estimator
FlxGrd(2).TextMatrix(i + 1, Recap.sDate) = .sDate
FlxGrd(2).TextMatrix(i + 1, Recap.BidAmount) = .BidAmount
FlxGrd(2).TextMatrix(i + 1, Recap.BidMaterial) = .BidMaterial
FlxGrd(2).TextMatrix(i + 1, Recap.Bid2Amount) = .Bid2Amount
FlxGrd(2).TextMatrix(i + 1, Recap.Bid2Material) = .Bid2Material
FlxGrd(2).TextMatrix(i + 1, Recap.sqs) = .sqs
FlxGrd(2).TextMatrix(i + 1, Recap.BusYrs) = .BusYrs
End With
Next
End Function
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: [RESOLVED] How to Save classes to binary file vb6
It might not be the populate, but the delete function. If you could play around (save your file as different name) and start a new file then add fake entries and play with the delete button... delete the first entry, if all good delete the third entry and see, it might be a delete bug, I thought I got it to work good but maybe it still needs adjustment.
I can easily do a function to remove any empty lines, but this does not fix the issue, unless you simply add an empty line by accident.
Re: [RESOLVED] How to Save classes to binary file vb6
So loop thru flxgrd(2).textmatrix(row,col),
Code:
Private Function Delete_EmptyCompany()
for i = 1 to .rows
if Trim(flxgrd(2).textmatrix(i,0)) = vbNullString then
CurrentCompany = i - 1 'This will set the company to delete (for Delete_Company)
Delete_Company
end if
next
End Sub
This is not tested I'm on my phone, but it should work.
I will check when I get a chance to see if it works, or you could try it
Re: [RESOLVED] How to Save classes to binary file vb6
Thanks,
if i knew this could happen i would have paid better attention.
I have written code for the save
eg;
msgbox Name cannot be missing.
I did notice when testing that if all the companies are deleted the fixed row looses it's color
In talking to my sister who is getting landscaping bids i have made a few visual minor adjustments
eg;
changed label Roof Company to Company etc
unfortunately i can no longer upload as i have installed some purchased ocx's http://www.namtuk.com/MyCommandButton-for-ActiveX.aspx
I will test your delete and try to recreate how the problem arose.
Thanks for your help
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders