Question

Change date per number VB6

Asked by: Wilder1626

Hello all,
This is part 2 of 3 posts, and lets go for the max points for all of them.
I need your help on a code that will change date for specific store number.
If we look at the image join to this post, we see in column 1 of the Flex Grid numbers that represent Store Numbers ex: 1530, 1531, 1535, 1536 and 1539.
In column 9, we have dates representing days of delivery.
Now what the code needs to do is that lest say that we have to move the delivery of the 10th of November because nobody is working, we need to move the date forward or backward depending on this logic.
For each stores, lets start with the first one 1530. He has a delivery date for Nov. 8, Nov 9, Nov. 10 and Nov. 12. but we need to change the date of the 10th.
So the code need to find when was the date that he had before the 10th and also find the next date after the 10th.
Before the 10th, it was the 9th. That was 1 day ago. But from the 10th to the 12th, it is 2 days later.
So since there more days after then before, it will change the date of the 10th to the 11th. And it will move on to the next store number 1531.
If the number of days would have been less after than before, it would of change the 10th to the 9th.
If it would have been equal, it would of change the 10th to 9th, I day before.

The date to cancel will be entered in a DTPicker1.

How can we do this please?

I know that its very hard, that's why I put extra points to this by splitting the post.
Thanks again


This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-08 at 15:05:30ID24882099
Tags

VB6

Topic

VB Script

Participating Experts
2
Points
500
Comments
26

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Flex Grid
    How do I allow user editing of data in a Flex Grid during runtime?
  2. Porting of Lex/Yacc code to Flex/Byacc
    I have an interactive parser built with lex/yacc that I'm trying to port to flex. It's giving me considerable problems. The code got compiled with just one issue where the yylineno was not found in flex. I have declared the yylineno to int and now it gets compiled. But when...
  3. Trace 'nobody' SPAMMER
    Specs: Centos (Linux) 4.2 Cpanel 10.x Exim 4.5 I need expert advice on how to trace any nobody spammer using any method to send FROM my server including forms, smtp, php, etc. PLEASE EXPLAIN EVERY POSSIBLE MEASURE TO TRACE A NOBODY USER. How do I trace this spammer sending...
  4. Flex AdvancedDataGrid
    Hi, I started to play around with Flex 3. I have managed to send an XML to my PHP backend (query database) and display the returning XML on the grid. Two columns are editable. What I am trying to do is, when user clicks on "Save Changes" button, Flex will create an ...
  5. Weekday Date Difference in flex
    How would you make a function that can tell the difference in weekdays (M-F) between two dates in flex? Also, how would you make a similar function to add a given number of weekdays to a date?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Brook1966Posted on 2009-11-09 at 05:38:55ID: 25775759

Your Ideal here is not difficult to do but confusing to understand "Exactly" what you want.
Let me re-state what I think you are saying so that I may help you better.

You wish to Locate the closest delivery date from a set of Company/Dates available.
You want to have a date picker to select the date and then find the appropriate record based on the given date so that.
A.  Once you find and exact match, you want to return that store number/date or the row.
B.  Return the same a option A for the row that has the path of least resistance ( which store will deliver sooner ).

Question:
1.  What do you wish to do when multiple stores have the same delivery date.
2.  What do you wish to do when multiple stores have the same number of days away from the requested delivery date.  ( one store may have the 9th while yet another has the 11th for a requested date of the 10th ) OR ( two stores have the 9th for a requested date of the 10th )

Is all you want to accomplish is finding the correct row?
This sounds more like a homework assignment.  :)

 

by: Brook1966Posted on 2009-11-09 at 05:41:53ID: 25775782

BTW:
It would be better coding ( in my opinion ) to get your answer in a query from the information you used to populate your grid in the first place. Similar to:

Select top 1 StoreID, DelDate, ABS(DELDATE - YOURDATE) AS DELDAYS
from YourData
order by DELDAYS DESC

 

by: Brook1966Posted on 2009-11-09 at 05:42:42ID: 25775791

or ascending for the smallest date :)

 

by: Wilder1626Posted on 2009-11-09 at 06:02:17ID: 25775957

You want to have a date picker to select the date and then find the appropriate record based on the given date so that.
A.  Once you find and exact match, you want to return that store number/date or the row.

answer: yes

B.  Return the same a option A for the row that has the path of least resistance ( which store will deliver sooner ).

answer: No.

Question:
1.  What do you wish to do when multiple stores have the same delivery date.

Answer: It has to find the date match per stores. So if there's a lot of stores with the same dates, it will take care of all stores but separately.

2.  What do you wish to do when multiple stores have the same number of days away from the requested delivery date.  ( one store may have the 9th while yet another has the 11th for a requested date of the 10th ) OR ( two stores have the 9th for a requested date of the 10th )

Answer: If the have the same number of days away from the requested delivery date, it will push back 1 day behind by default.

We really have to treat all stores separately, one by one.

I hope this answered your questions.

Thanks for your help.

 

by: Wilder1626Posted on 2009-11-09 at 07:22:31ID: 25776646

So you say that it would be better coding to get answer in a query from the information I used to populate my grid ?

How can I do this?

 

by: Brook1966Posted on 2009-11-09 at 08:50:19ID: 25777621

Here is a sample query you could use ( assumes SQL syntax I do not know what you are using )

SELECT C.COMPID, MAX(D.DELDATE) AS NDELDATE, ABS(D.DELDATE - CHOSENDATE) AS DYDIFF
FROM COMPANY C
LEFT JOIN DELIVERYSCHED D ON D.COMPID = C.COMPID
GROUP BY C.COMPID, DYDIFF
HAVING DYDIFF = 
( SELECT MIN(D2.DELDATE - CHOSENDATE)
    FROM COMPANY C2
         LEFT JOIN DELIVERYSCHED D2 ON D2.COMPID = C2.COMPID
   WHERE C2.COMPID = C.COMPID
   GROUP BY C.COMPID )
ORDER BY DYDIFF

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:

Select allOpen in new window

 

by: Brook1966Posted on 2009-11-09 at 08:51:25ID: 25777635

The query above will give you a list of the companies with the delivery date ordered by the least number of days from the delivery date.

I hope this helps you.

 

by: Wilder1626Posted on 2009-11-09 at 09:22:30ID: 25777950

I'm not use to SQL, It doesnt work with SQL code also. Only VB6?.

I'm not familiar with SQL also.

His there another way of doing this?

 

by: Wilder1626Posted on 2009-11-09 at 09:23:42ID: 25777964

Just to let you know, the data come's from an excel spreadsheet, and introduce into a Grid.

 

by: robberbaronPosted on 2009-11-10 at 04:01:54ID: 25784522

try this.... dont get your logic much.

1/ waht happens if there is no date before or no date after the checkdate ?  I've assumes the checkdate but i think that gives erroneous dates.
2/ my code writes to the 7th column just so that i can see what it has done. change the fix lines to write to column 9 when ok.
3/ Note my code uses mmm/dd/yyyy as not everyone uses the US date format in windows. Using mmm forces an unambiguous date string that is always converted to a date value correctly.

Private Sub Command3_Click()
    'now update the column 7 with new delivery date'
    'start at row1..'
    'check if value different'
    '  if not then update max & min'
    Dim dtCheck As Date, dtTest As Date, i As Integer, x As Integer
    Dim storeId As Long, dtEarly As Date, dtLate As Date, iRowSt As Integer, iRowEnd As Integer
    Dim iDelay As Integer
    Dim iDaysEarly As Integer, iDaysAfter As Integer
    dtCheck = DTPicker1.Value
    storeId = 0
    iRowSt = 1: iRowEnd = 0
 
    For i = 1 To Form3.msfWindows.Rows - 1 
        If storeId = Form3.msfWindows.TextMatrix(i, 0) Then
            'update edn id' 
            iRowEnd = i
        Else
            'process stats'
            If iRowSt <> 0 And iRowEnd <> 0 Then
                'have valid data'
                iDaysEarly = DateDiff("d", dtCheck, dtTest)
                iDaysAfter = DateDiff("d", dtCheck, dtLate)
                
                If iDaysAfter > iDaysEarly Then
                    iDelay = 1
                 ElseIf iDaysAfter < iDaysEarly Then
                    iDelay = -1
                 Else
                    iDelay = -1
                End If
                For x = iRowSt To iRowEnd
                    'check if date is to be missed'
                    If Form3.msfWindows.TextMatrix(x, 9) = dtCheck Then
                        'modify date'
                        Form3.msfWindows.TextMatrix(x, 7) = Format(dtCheck + iDelay, "mmm/DD/yyyy")
                    End If
                Next x
            End If
            'set next id'
            storeId = Form3.msfWindows.TextMatrix(i, 0)
            dtEarly = dtCheck: dtLate = dtCheck 

            
            iRowSt = i: iRowEnd = i
        End If
        dtTest = Form3.msfWindows.TextMatrix(i, 9)  'the date delivery planned'
        If dtTest > dtCheck And dtTest < dtLate Then
            dtLate = dtTest
        End If
        If dtTest < dtCheck And dtTest > dtEarly Then
            dtEarly = dtTest
        End If
    Next 
    'force a process for last cells'
        'process stats'
        If iRowSt <> 0 And iRowEnd <> 0 Then
            'have valid data'
            iDaysEarly = DateDiff("d", dtCheck, dtTest)
            iDaysAfter = DateDiff("d", dtCheck, dtLate)
            
            If iDaysAfter > iDaysEarly Then
                iDelay = 1
             ElseIf iDaysAfter < iDaysEarly Then
                iDelay = -1
             Else
                iDelay = -1
            End If
            For x = iRowSt To iRowEnd
                'check if date is to be missed'
                If Form3.msfWindows.TextMatrix(x, 9) = dtCheck Then
                    'modify date'
                    Form3.msfWindows.TextMatrix(x, 7) = Format(dtCheck + iDelay, "mmm/DD/yyyy")
                End If
            Next x
        End If 

    
    
End Sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:

Select allOpen in new window

 

by: Wilder1626Posted on 2009-11-10 at 04:13:08ID: 25784575

Hello,

Thanks.

I have an error of type mismatch on:


Do you know what it is?

If storeId = Form3.MSFWindows.TextMatrix(i, 0) Then

                                              
1:

Select allOpen in new window

 

by: Wilder1626Posted on 2009-11-10 at 11:33:09ID: 25788846

It seems that storeId = 10.

I don't know where it take the 10 value.

 

by: robberbaronPosted on 2009-11-10 at 14:08:55ID: 25790433

in line 41...     storeId = Form3.msfWindows.TextMatrix(i, 0)

ie the value of column 0. maybe this should be column 1 in your code, when you would need to chnage line 15 as well.

 

by: Wilder1626Posted on 2009-11-10 at 14:19:45ID: 25790519

That's good.

Now storeId = store number. But still type mismatch error on:

Form3.MSFWindows.TextMatrix(i, 1)  Then= ""

If storeId = Form3.MSFWindows.TextMatrix(i, 1) Then

                                              
1:

Select allOpen in new window

 

by: Wilder1626Posted on 2009-11-10 at 14:30:10ID: 25790619

What I can see is that it doesnt want to see: Form3.MSFWindows.TextMatrix(I, 1) and also Form3.MSFWindows.TextMatrix(I, 9) later on the code.

I validate that the form is Form3, and it is.

Both of them give "" for value.

Do you know why?

 

by: robberbaronPosted on 2009-11-10 at 23:45:31ID: 25792995

you need to change the row and column ids to suit your application.
I'm just guessing the column numbers based upon your screen shots and past question.

each reference to MSFWindows.TextMatrix  needs to have the correct  (row, column).  Note that each start at zero!

also, Form3 is not a useful name, Should change it (and all refereces) to somthing a bit descriptive. Such as frmFixDate, where the frm is a prefix I use so that its easy to see that im refering to a form, just like MSF (though i use fgd for flexgrid)

 

by: Wilder1626Posted on 2009-11-11 at 03:44:00ID: 25794204

I did what you told me, to change the name of the form. After, the row and column or good. I did some test by changing column value, but still the same problem.

Here is the result that i have:

 

by: Wilder1626Posted on 2009-11-11 at 04:11:15ID: 25794341

It seems like there a problem with the variable (i).

If i change (i) with (x), i have  a result, but the problem comes back if i re run again the code. It is very weird.

 

by: robberbaronPosted on 2009-11-12 at 03:28:24ID: 25803313

you must have a column name or variable incorrect.

i've attached my entire test code for you to review.

add 2 command buttons to go with the flexgrid and dtpicker.

click the button2 to load test data, button1 to process dates into column 7


Option Explicit
Dim daynames(7)  'make a module level declaration'
Sub AddDateColumn()
    'the action button'
    Dim dtNow, dtMon, i, test
    
    msfWindows.ColWidth(9) = -1  'reset the column back to default size'
    For i = 1 To Form3.msfWindows.Rows - 1
        test = Form3.msfWindows.TextMatrix(i, 8)
        If Form3.msfWindows.TextMatrix(i, 8) > "" Then
        
            dtNow = DateofLastDay(test)
            Form3.msfWindows.TextMatrix(i, 9) = Format(dtNow, "mmm/DD/yyyy")
        End If
    Next
End Sub 
Private Sub Command3_Click()
    'now update the column 7 with new delivery date'
    'start at row1..'
    'check if value different'
    '  if not then update max & min'
    Dim dtCheck As Date, dtTest As Date, i As Integer, x As Integer
    Dim storeId As Long, dtEarly As Date, dtLate As Date, iRowSt As Integer, iRowEnd As Integer
    Dim iDelay As Integer
    Dim iDaysEarly As Integer, iDaysAfter As Integer
    dtCheck = DTPicker1.Value
    storeId = 0
    iRowSt = 1: iRowEnd = 0
 
    For i = 1 To Form3.msfWindows.Rows - 1 
        If storeId = Form3.msfWindows.TextMatrix(i, 0) Then
            'update edn id' 
            iRowEnd = i
        Else
            'process stats'
            If iRowSt <> 0 And iRowEnd <> 0 Then
                'have valid data'
                iDaysEarly = DateDiff("d", dtCheck, dtTest)
                iDaysAfter = DateDiff("d", dtCheck, dtLate)
                
                If iDaysAfter > iDaysEarly Then
                    iDelay = 1
                 ElseIf iDaysAfter < iDaysEarly Then
                    iDelay = -1
                 Else
                    iDelay = -1
                End If
                For x = iRowSt To iRowEnd
                    'check if date is to be missed'
                    If Form3.msfWindows.TextMatrix(x, 9) = dtCheck Then
                        'modify date'
                        Form3.msfWindows.TextMatrix(x, 7) = Format(dtCheck + iDelay, "mmm/DD/yyyy")
                    End If
                Next x
            End If
            'set next id'
            storeId = Form3.msfWindows.TextMatrix(i, 0)
            dtEarly = dtCheck: dtLate = dtCheck 

            
            iRowSt = i: iRowEnd = i
        End If
        dtTest = Form3.msfWindows.TextMatrix(i, 9)  'the date delivery planned'
        If dtTest > dtCheck And dtTest < dtLate Then
            dtLate = dtTest
        End If
        If dtTest < dtCheck And dtTest > dtEarly Then
            dtEarly = dtTest
        End If
    Next 
    'force a process for last cells'
        'process stats'
        If iRowSt <> 0 And iRowEnd <> 0 Then
            'have valid data'
            iDaysEarly = DateDiff("d", dtCheck, dtTest)
            iDaysAfter = DateDiff("d", dtCheck, dtLate)
            
            If iDaysAfter > iDaysEarly Then
                iDelay = 1
             ElseIf iDaysAfter < iDaysEarly Then
                iDelay = -1
             Else
                iDelay = -1
            End If
            For x = iRowSt To iRowEnd
                'check if date is to be missed'
                If Form3.msfWindows.TextMatrix(x, 9) = dtCheck Then
                    'modify date'
                    Form3.msfWindows.TextMatrix(x, 7) = Format(dtCheck + iDelay, "mmm/DD/yyyy")
                End If
            Next x
        End If 

    
    
End Sub 
Sub Command2_Click()
    'fill Flexgrid with test data'
    Dim i
    daynames(1) = "Sun"
    daynames(2) = "Mon"
    daynames(3) = "Tues"
    daynames(4) = "Wed"
    daynames(5) = "Thur"
    daynames(6) = "Fri"
    daynames(7) = "Sat"
    
    msfWindows.Clear
    msfWindows.Rows = 1
    msfWindows.Cols = 10
    Randomize
    For i = 0 To 9
        Form3.msfWindows.TextMatrix(0, i) = i
    Next
    For i = 1 To 8
        msfWindows.AddItem Format(Rnd(1) * 3 + 1530, "####") & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & "az" & vbTab & "---" & vbTab & daynames(Rnd(1) * 7 + 0.49) & vbTab & "ZZZ"
    Next i
    
    msfWindows.ColWidth(9) = 0  'make day num invisible'
    
    AddDateColumn
    
End Sub 
Function DateofLastDay(sDayName)
    Dim x1, x2, y, i
    x1 = Weekday(Now(), vbSunday)  'what day of week is today'
    For y = 1 To 7
        If daynames(y) = sDayName Then
            'found the correct daynum'
            Exit For
        End If
    Next y
    If y > 7 Then
        MsgBox "Could not match day name"
        DateofLastDay = 0
        Exit Function
    End If
    
    x2 = DateAdd("D", y - x1, Now())  'return a date so can be formatted as desired'
    
    DateofLastDay = x2
    SortByColumn 0, msfWindows
End Function
'----------------'
'original idea from http://www.vb-helper.com/howto_sort_flexgrid.html'
'-----------------'
Private Sub msfWindows_MouseUp(Button As Integer, Shift As _
    Integer, x As Single, y As Single)
    ' If this is not row 0, do nothing.'
    If msfWindows.MouseRow <> 0 Then Exit Sub 
    ' Sort by the clicked column.'
    SortByColumn msfWindows.MouseCol, msfWindows
End Sub 
' Sort by the indicated column.'
Private Sub SortByColumn(ByVal sort_column As Integer, flgTarget As MSFlexGrid)
    ' Hide the FlexGrid.'
    Dim m_SortColumn As Integer, m_SortOrder As Integer
    
    flgTarget.Visible = False
    flgTarget.Refresh 
    ' Sort using the clicked column.'
    flgTarget.Col = sort_column
    flgTarget.ColSel = sort_column
    flgTarget.Row = 0
    flgTarget.RowSel = 0 
    ' If this is a new sort column, sort ascending.'
    ' Otherwise switch which sort order we use.'
    If m_SortColumn <> sort_column Then
        m_SortOrder = flexSortGenericAscending
    ElseIf m_SortOrder = flexSortGenericAscending Then
        m_SortOrder = flexSortGenericDescending
    Else
        m_SortOrder = flexSortGenericAscending
    End If
    flgTarget.Sort = m_SortOrder 
    ' Restore the previous sort column's name.'
    If m_SortColumn >= 0 Then
        flgTarget.TextMatrix(0, m_SortColumn) = _
            Mid$(flgTarget.TextMatrix(0, m_SortColumn), 3)
    End If 
    ' Display the new sort column's name.'
    m_SortColumn = sort_column
    If m_SortOrder = flexSortGenericAscending Then
        flgTarget.TextMatrix(0, m_SortColumn) = "> " & _
            flgTarget.TextMatrix(0, m_SortColumn)
    Else
        flgTarget.TextMatrix(0, m_SortColumn) = "< " & _
            flgTarget.TextMatrix(0, m_SortColumn)
    End If 
    ' Display the FlexGrid.'
    flgTarget.Visible = True
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:

Select allOpen in new window

 

by: Wilder1626Posted on 2009-11-12 at 04:07:10ID: 25803558

Yes, i think that we are getting closer and closer.

I have a type mismatch error:

Thank you so much for your help

 

by: robberbaronPosted on 2009-11-13 at 03:38:18ID: 25813074

daynames should be dim as string, or left blank means it is variant.
You must have this dim at a module level.

 

by: Wilder1626Posted on 2009-11-13 at 04:39:10ID: 25813397

Ok, if i understand right, all this code (Dim as) should be moved in a module?

Function daynames
 'fill Flexgrid with test data'
    Dim i
    Dim daynames
    'On Error Resume Next
    daynames(1) = "Sun"
    daynames(2) = "Mon"
    daynames(3) = "Tue"
    daynames(4) = "Wed"
    daynames(5) = "Thu"
    daynames(6) = "Fri"
    daynames(7) = "Sat"
    
    MSFWindows.Clear
    MSFWindows.Rows = 1
    MSFWindows.Cols = 10
    Randomize
    For i = 0 To 9
        windows_charts.MSFWindows.TextMatrix(0, i) = i
    Next
    For i = 1 To 8
        MSFWindows.AddItem Format(Rnd(1) * 3 + 1530, "####") & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & Rnd(1) * 50 & vbTab & "az" & vbTab & "---" & vbTab & daynames(Rnd(1) * 7 + 0.49) & vbTab & "ZZZ"
    Next i
    
    MSFWindows.ColWidth(9) = 0  'make day num invisible'
    
    AddDateColumn
    
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

Select allOpen in new window

 

by: robberbaronPosted on 2009-11-13 at 17:50:38ID: 25819015

Unsure.
1/ I'm assuming you are really using VB6 , rather than VBS, this is actually the VBS topic area


2/ if you are using my test code, it had a Dim daynames(7) as the second line. Since this is outside any Sub or Function, this is termed a module or form level declaration.
in which case the Dim Daynames in the function should be deleted.


3/ If you are merging my functions into your code, then ensure the form level dim daynames(7) is deleted and change

Dim daynames  ---> Dim dayNames(7) as string
 within the function itself./



 

by: Wilder1626Posted on 2009-11-14 at 06:24:56ID: 25820834

Very impressive as results.

I'm trying to understand each columns because I see store numbers that is not appearing in my grid.

Ex: 1532. In the grid on top, 1532 is not in the list but is in the result on the bottom.

For 1531, in the top grid, column 8, I have a Monday and Thursday delivery but in the bottom grid, 1531 have a Monday and Friday delivery.

For the results, in column 7 of the bottom grid, the results is always 1 day less also.

Thanks again

 

by: robberbaronPosted on 2009-11-14 at 18:12:48ID: 25823339

my data is test only. I dont have yours to use!

if daysafter = daysbefore, then it defaults to using the day before. thsi would be the case if store only exists once (which happens often with my random test data)

you need to review my logic
              If iDaysAfter > iDaysEarly Then
                     iDelay = 1
                ElseIf iDaysAfter < iDaysEarly Then
                     iDelay = -1
                Else
                      iDelay = -1
               End If


 

by: Wilder1626Posted on 2009-11-15 at 03:38:46ID: 31654345

A big thanks to you.

Next part in another post

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...