VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 307,127 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,051 people online right now. Registration is fast and FREE... Join Now!




VB6 find and replace issue

 

VB6 find and replace issue

wilder

31 Oct, 2009 - 03:03 PM
Post #1

New D.I.C Head
*

Joined: 12 Apr, 2009
Posts: 10


My Contributions
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 1009 have multiple delivery days ex:
CODE

Column 2               Culumn 20
1009                      Mon
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.

This post has been edited by wilder: 1 Nov, 2009 - 02:54 PM

User is offlineProfile CardPM
+Quote Post


June7

RE: VB6 Find And Replace Issue

31 Oct, 2009 - 07:38 PM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Dec, 2008
Posts: 485



Thanked: 38 times
My Contributions
Need to show code for analysis.
User is offlineProfile CardPM
+Quote Post

wilder

RE: VB6 Find And Replace Issue

1 Nov, 2009 - 05:05 AM
Post #3

New D.I.C Head
*

Joined: 12 Apr, 2009
Posts: 10


My Contributions
What i did for now is to change the day with a number:

CODE
For i = 8 To Form3.MSFWindows.Rows - 1
  If Form3.MSFWindows.TextMatrix(i, 20) = "Sun" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "1"
  End If
  
   If Form3.MSFWindows.TextMatrix(i, 20) = "Mon" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "2"
  End If
  
   If Form3.MSFWindows.TextMatrix(i, 20) = "Tue" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "3"
  End If
  
   If Form3.MSFWindows.TextMatrix(i, 20) = "Wed" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "4"
  End If
  
   If Form3.MSFWindows.TextMatrix(i, 20) = "Thu" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "5"
  End If
  
   If Form3.MSFWindows.TextMatrix(i, 20) = "Fri" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "6"
  End If
  
   If Form3.MSFWindows.TextMatrix(i, 20) = "Sat" Then
  Form3.MSFWindows.TextMatrix(i, 20) = "7"
  End If
  Next i



and what it should do is something like this:
CODE

If Monday to Friday > Friday to Monday then
2 ("Mon" value) = 2+1

else

If Monday to Friday < Friday to Monday then
2 ("Mon" value) = 2-1


else
2 ("Mon" value) = 2-1

User is offlineProfile CardPM
+Quote Post

thava

RE: VB6 Find And Replace Issue

1 Nov, 2009 - 04:26 PM
Post #4

D.I.C Addict
Group Icon

Joined: 17 Apr, 2007
Posts: 905



Thanked: 52 times
Dream Kudos: 75
My Contributions
mon - fri = 4
fri-mon =3

explain a little bit and show your whole grid is hat your grid holds the weekday number if yes then it is simple else store that number also
and hide it now it's so simpler to you

may i know why should you do this
to me there is some logic miss



User is offlineProfile CardPM
+Quote Post

wilder

RE: VB6 Find And Replace Issue

1 Nov, 2009 - 05:46 PM
Post #5

New D.I.C Head
*

Joined: 12 Apr, 2009
Posts: 10


My Contributions
Here is a part of my grid to show you more. I took of the extra data since there's a lot.

This data comes from another program. so I can modify it except for changing days.

Since I will use the code only to modify week with holiday, it's not a weekly tool but could save a lot of time since I have thousands of line in that grid.

I just need to change the holiday.

So if the store in the grid have 2 days of delivery, only the holiday will be change.

When you say:
Mon - Fri = 4
Fri-Mon =3

If I take the example of the picture attached to this post, 1503. As you can see, he's got a delivery on Monday, and on Thursday. If the holiday, or the day OFF is on Monday, it will have to change that day.

The logic is that the holiday Monday, will be forwarded to Tuesday or it will be move to Sunday.

How do we determine that?

It will calculate the number of day between Monday to the next day and also Monday to the last delivery just before.

So in both days for store 1503, We only have Monday and Thursday.

So Monday to Thursday = 3 days and Thursday to Monday = 4 days.

Since Monday to Thursday < Thursday to Monday then I will move Monday backward -1. So Sunday.

If I would of done the opposite way, so Monday + 1, Tuesday to Thursday = 2 days and Thursday to Tuesday = 5 days. So to long between deliveries.


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

thava

RE: VB6 Find And Replace Issue

3 Nov, 2009 - 04:28 PM
Post #6

D.I.C Addict
Group Icon

Joined: 17 Apr, 2007
Posts: 905



Thanked: 52 times
Dream Kudos: 75
My Contributions
how did you find whether a day is holiday did you have any other table

according to your statement alternate rows are the deliveryday
but note the shop no 1506 it has only wednesday how could you determine the delivery date

ok listen now add a column in this grid and hide it, for each row in the grid add the corresponding day no

in a for loop check whether the day is holiday then do your logic there if you can post this form's code here surely, i will help you

User is offlineProfile CardPM
+Quote Post

wilder

RE: VB6 Find And Replace Issue

4 Nov, 2009 - 02:27 PM
Post #7

New D.I.C Head
*

Joined: 12 Apr, 2009
Posts: 10


My Contributions
QUOTE(thava @ 3 Nov, 2009 - 04:28 PM) *
ok listen now add a column in this grid and hide it, for each row in the grid add the corresponding day no

in a for loop check whether the day is holiday then do your logic there if you can post this form's code here surely, i will help you


So i could add a column:
CODE
With MSFWindows
.ColPosition(.Cols - 1) = .Col
End With


But how can I manage to add the corresponding day no?

All day are this format: Sun, Mon, Tue ....... Mon, Tue .......

But i like your idea!

best regards
User is offlineProfile CardPM
+Quote Post

thava

RE: VB6 Find And Replace Issue

8 Nov, 2009 - 03:56 PM
Post #8

D.I.C Addict
Group Icon

Joined: 17 Apr, 2007
Posts: 905



Thanked: 52 times
Dream Kudos: 75
My Contributions
it's simple use a for loop and use a select statement to do this
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 02:29PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month