944,039 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Oct 31st, 2009
0

VB6 find and replace

Expand Post »
Hello everybody,

I have an issue with a code. I'm don't know how to start this.

Here is my problem:
Column 2 of my MSFlexgrid = store number. Ex: 1009,1010 etc.

In column 20 of my MSFlexgrid = Delivery day. Ex: Sun, Mon, Tue......,

Now if store 8009 have multiple delivery days ex:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Column 2 Culumn 20
  2. 1009 Mon
  3. 1009 Fri

The logic will have to be that way:
If the the holiday entered in the Form4.day_ferier (Combo Box) is "Mon"
Then it will calculate how many day it will have until the next delivery.

In that case,Monday to Friday = 4 days.

Then it will calculate how many days there was from the previous delivery. Friday to Monday = 3 days.

So since Monday to Friday is bigger that Friday to monday, then the results will be Monday +1. So Tuesday.

If the result would of been less, then it would of been Monday - 1. So Sunday.

If it would of been equal, by default, it would be Monday - 1.

Would it be easier if I change Sun by "1", Mon by "2", Tue by "3" and so on...

Thank you so much for your help.
Last edited by wilder1926; Oct 31st, 2009 at 8:32 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wilder1926 is offline Offline
9 posts
since Oct 2009
Nov 1st, 2009
0
Re: VB6 find and replace
you are struck in which part ?
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Nov 1st, 2009
0
Re: VB6 find and replace
What i did for now if to convert the days for numbers:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. For i = 8 To Form3.MSFWindows.Rows - 1
  2. If Form3.MSFWindows.TextMatrix(i, 20) = "Sun" Then
  3. Form3.MSFWindows.TextMatrix(i, 20) = "1"
  4. End If
  5.  
  6. If Form3.MSFWindows.TextMatrix(i, 20) = "Mon" Then
  7. Form3.MSFWindows.TextMatrix(i, 20) = "2"
  8. End If
  9.  
  10. If Form3.MSFWindows.TextMatrix(i, 20) = "Tue" Then
  11. Form3.MSFWindows.TextMatrix(i, 20) = "3"
  12. End If
  13.  
  14. If Form3.MSFWindows.TextMatrix(i, 20) = "Wed" Then
  15. Form3.MSFWindows.TextMatrix(i, 20) = "4"
  16. End If
  17.  
  18. If Form3.MSFWindows.TextMatrix(i, 20) = "Thu" Then
  19. Form3.MSFWindows.TextMatrix(i, 20) = "5"
  20. End If
  21.  
  22. If Form3.MSFWindows.TextMatrix(i, 20) = "Fri" Then
  23. Form3.MSFWindows.TextMatrix(i, 20) = "6"
  24. End If
  25.  
  26. If Form3.MSFWindows.TextMatrix(i, 20) = "Sat" Then
  27. Form3.MSFWindows.TextMatrix(i, 20) = "7"
  28. End If
  29. Next i

After, i tried something like:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim i%
  2.  
  3. For i = 8 To Form3.MSFWindows.Rows - 1
  4. opid = Form3.MSFWindows.TextMatrix(i, 1)
  5. Day1 = day_ferier.Text
  6.  
  7. For Each opid In Form3.MSFWindows
  8. If Form3.MSFWindows.TextMatrix(i, 20) = Day1 And Form3.MSFWindows.TextMatrix(i, 1) = opid Then
  9. Form3.MSFWindows.TextMatrix(i, 20) = Form3.MSFWindows.TextMatrix(i, 20) + 1
  10. End If
  11. Next
  12.  
  13. Next
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wilder1926 is offline Offline
9 posts
since Oct 2009
Nov 2nd, 2009
0
Re: VB6 find and replace
It seems you have a problem in solving date/Times solutions.
What exactly do you want to achieve with your code? I presume that the result should show up in your datagrid?
Do you want to run reports from certain dates etc? or wouyld you like vb6 app to calculate the next dekivery date?
Reputation Points: 329
Solved Threads: 347
Senior Poster
AndreRet is offline Offline
3,700 posts
since Jan 2008
Nov 2nd, 2009
0
Re: VB6 find and replace
Click to Expand / Collapse  Quote originally posted by AndreRet ...
It seems you have a problem in solving date/Times solutions.
What exactly do you want to achieve with your code? I presume that the result should show up in your datagrid?
Do you want to run reports from certain dates etc? or wouyld you like vb6 app to calculate the next dekivery date?
What exactly do you want to achieve with your code? I want the code to modify the date that need to be modify in the flexgrid.

Do you want to run reports from certain dates etc? No reports will be run.

would you like vb6 app to calculate the next delivery date?

Yes, It must calculate the delivery day that need to be modify, and replace it in the flexgrid. But replace only the day that need to be modify.

Thanks
Last edited by wilder1926; Nov 2nd, 2009 at 6:29 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wilder1926 is offline Offline
9 posts
since Oct 2009
Nov 3rd, 2009
0
Re: VB6 find and replace
Where is your grid getting its data from? You will probably have to play around with vbdate functions.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If Form3.MSFWindows.TextMatrix(i, 20) = "Sun" 'vbSunday Then
  2. Form3.MSFWindows.TextMatrix(i, 20) = "1"
  3.  
  4. 'Try functions like vbSunday, vbDate etc.
  5. End If
Reputation Points: 329
Solved Threads: 347
Senior Poster
AndreRet is offline Offline
3,700 posts
since Jan 2008
Nov 3rd, 2009
0
Re: VB6 find and replace
I like your code, i really do but this part was not really my first problem.

My problem is more what i was saying in my first post:
If the the holiday entered in the Form4.day_ferier (Combo Box) is "Mon"
Then it will calculate how many day it will have until the next delivery.

In that case,Monday to Friday = 4 days.

Then it will calculate how many days there was from the previous delivery. Friday to Monday = 3 days.

So since Monday to Friday is bigger that Friday to monday, then the results will be Monday +1. So Tuesday.

If the result would of been less, then it would of been Monday - 1. So Sunday.

If it would of been equal, by default, it would be Monday - 1.
regards
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wilder1926 is offline Offline
9 posts
since Oct 2009
Nov 7th, 2009
0
Re: VB6 find and replace
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If Form3.MSFWindows.TextMatrix(i, 20) = "Sat" Then Form3.MSFWindows.TextMatrix(i, 20) = "7" End If
I'm not familiar with flexigrid but if the grid was set to a day of the week could you not just change the setup to show the day number of the week?
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
Nov 8th, 2009
0
Re: VB6 find and replace
Click to Expand / Collapse  Quote originally posted by Jupiter 2 ...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If Form3.MSFWindows.TextMatrix(i, 20) = "Sat" Then Form3.MSFWindows.TextMatrix(i, 20) = "7" End If
I'm not familiar with flexigrid but if the grid was set to a day of the week could you not just change the setup to show the day number of the week?

That's good, it give's me an idea.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wilder1926 is offline Offline
9 posts
since Oct 2009
Nov 8th, 2009
0
Re: VB6 find and replace
Also, if you are using an actual date then maybe use the DateValue rather than the day word. The DateValue is the decimal number of the date eg 6564532 (or whatever) then subtract one number from the other.
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 database Help Required
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: SQL command for calculating Ave from multiple tables





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC