VB6 find and replace

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 9
Reputation: wilder1926 is an unknown quantity at this point 
Solved Threads: 0
wilder1926 wilder1926 is offline Offline
Newbie Poster

VB6 find and replace

 
0
  #1
Oct 31st, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,134
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 132
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic
 
0
  #2
Nov 1st, 2009
you are struck in which part ?
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 9
Reputation: wilder1926 is an unknown quantity at this point 
Solved Threads: 0
wilder1926 wilder1926 is offline Offline
Newbie Poster
 
0
  #3
Nov 1st, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 255
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 38
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #4
Nov 2nd, 2009
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?
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 9
Reputation: wilder1926 is an unknown quantity at this point 
Solved Threads: 0
wilder1926 wilder1926 is offline Offline
Newbie Poster
 
0
  #5
Nov 2nd, 2009
Originally Posted by AndreRet View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 255
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 38
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #6
Nov 3rd, 2009
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
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 9
Reputation: wilder1926 is an unknown quantity at this point 
Solved Threads: 0
wilder1926 wilder1926 is offline Offline
Newbie Poster
 
0
  #7
Nov 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #8
Nov 7th, 2009
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?
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 9
Reputation: wilder1926 is an unknown quantity at this point 
Solved Threads: 0
wilder1926 wilder1926 is offline Offline
Newbie Poster
 
0
  #9
Nov 8th, 2009
Originally Posted by Jupiter 2 View Post
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.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #10
Nov 8th, 2009
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.
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Reply

Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC