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:

``````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.

All 16 Replies

you are struck in which part ?

What i did for now if to convert the days for numbers:

``````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``````

After, i tried something like:

``````Dim i%

For i = 8 To Form3.MSFWindows.Rows - 1
opid = Form3.MSFWindows.TextMatrix(i, 1)
Day1 = day_ferier.Text

For Each opid In Form3.MSFWindows
If Form3.MSFWindows.TextMatrix(i, 20) = Day1 And Form3.MSFWindows.TextMatrix(i, 1) = opid Then
Form3.MSFWindows.TextMatrix(i, 20) = Form3.MSFWindows.TextMatrix(i, 20) + 1
End If
Next

Next``````

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?

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

Where is your grid getting its data from? You will probably have to play around with vbdate functions.

``````If Form3.MSFWindows.TextMatrix(i, 20) = "Sun" 'vbSunday Then
Form3.MSFWindows.TextMatrix(i, 20) = "1"

'Try functions like vbSunday, vbDate etc.
End If``````

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

``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 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.

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.

Another thing, you should be using variables and not the actual references. Dimension the values then format number. If this is supposed to be a professional project, using actual references is considered poor programming.

Another thing, you should be using variables and not the actual references. Dimension the values then format number. If this is supposed to be a professional project, using actual references is considered poor programming.

Being a beginner in VB6, I don't understand when you say to not use actual references.

What do you mean by this?

What I did is that it add a temporary column beside the day name, and it put the real date format: 11/09/2009. Is that good?

With that format, is it better to resolve the rest?

Thanks again for your help.

``````If Form3.MSFWindows.TextMatrix(i, 20) = "Sun" 'vbSunday Then  Form3.MSFWindows.TextMatrix(i, 20) = "1"   'Try functions like vbSunday, vbDate etc.End IfIf Form3.MSFWindows.TextMatrix(i, 20) = "Sun" 'vbSunday Then
Form3.MSFWindows.TextMatrix(i, 20) = "1"
'Try functions like vbSunday, vbDate etc.
End If``````
``````Sub DangFool()
Dim intNum as integer
Dim strNum as string
Dim VarNum as Variant

intNum=5
strNum="Five"
varNum=Form3.MSFWindows.TextMatrix(i, 20)
End Sub``````

This is just a sample. You should have learnt about variables in class.

No sorry, i'm learning VB6 by my self, with books and Forums, not in a class.

Learning by yourself is a hard task . I taught myself VBA (for excel) back in 1995 but in 2001 did a catch up course to ensure I understood the varibles and update information. I did a Diploma of IT but only as far as much as I wanted to learn. I actually didn't want the Diploma. The course was paid for by a local Job Network (Australia) and they paid for books.

The only thing I can suggest is to acquire the "Programming in Visual Basic 6" published by McGraw-Hill Irwin Student Edition. Do the exercises and read everything 10 times over.

Here are my sample utilities using vb6 -

I still have to upload my Excel files but most of my VB6 utilities are loaded. Sorry, no source code, though.

I'm not an expert by any means. I'm basically self-taught.

You can still do what you do just for exercise but try to learn about variables and Dim-ensioning. It is a lot more code to write just to do a task but it will work faster and better.

You have called the form "Form3" does this mean there are 2 other forms?

Thanks for your help, and I should really go and take a course.
I will take a good look at your web page also.

As for the Form3 question, yes, I have 3 forms.

best regards

What are you actually trying to achieve with the Flexigrid?

Is this an Add-In for other programs or is is for use as a stand-alone program utility?

Perhaps Excel might be better suited if you want to manipulate data. Excel is much easier to use than Access and there is a lot more people who can help with Excel problems than with Access.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.