Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2005, 11:15 AM
Authorized User
 
Join Date: Oct 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default weird program flow with nested functions

When the first function (LastDateInSheet) is executed from a form_load event, the program flow jumps from the 4th line to the function immediately below.

   Public Function LastDateInSheet() As Date
        Dim DateRow As Range, ws As Worksheet = wb.ActiveSheet
        DateRow = ws.Range("2:2")

'Jumps from the line below to next function below ????
        LastDateInSheet = Date.FromOADate(xl.WorksheetFunction.Max(DateRow))

        DateRow = Nothing
        ws = Nothing
    End Function
--------------------------------------------------------------------
    Public Function DateRange(ByVal D As Date) As Range

        'Returns the location (range) of a date in vbGrid.xls
        'ACTIVATES the sheet with the date

        Dim WS As Worksheet

        WS = wb.ActiveSheet

'Jumps to the line below ????????
        DateRange = WS.Range("a2:ba2").Find(D)
        If Not DateRange Is Nothing Then Exit Function

        'If date is not on active sheet, then find it
        ' wb.ActiveSheet.GetType()
        If WS.Name = "Data" Then wb.ActiveSheet.Previous.Activate()

any ideas??

vmz
__________________
vmz
 
Old January 6th, 2006, 11:06 AM
Registered User
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Examine the call stack when the code breaks into the DateRange function.

At a guess, when you call xl.worksheetfunction.max(DateRow) then an event is being fired that calls the DateRange function the call stack should show this.

From here you should be able to sort out whats going on.

If you continue to step through, does the code return to the lastdateinsheet function and carry on?


Cheers

Squatss









Similar Threads
Thread Thread Starter Forum Replies Last Post
Flow chart of Cobol program in dotNet SOANS General .NET 0 November 20th, 2007 11:29 PM
Program Flow Interrupted By IF...THEN Statement squeege321 Pro VB 6 10 March 23rd, 2007 11:38 AM
Flow of the Program ? pandian Java Basics 2 March 20th, 2006 11:07 PM
weird program flow with nested loops zayasv Intro Programming 2 November 17th, 2005 06:19 AM
weird program flow with nested functions zayasv VB.NET 0 October 26th, 2005 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.