says function is undefined
says function is undefined
says function is undefined
says function is undefined
says function is undefined
says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined
says function is undefined says function is undefined
says function is undefined
Go Back  Xtreme Visual Basic Talk > > > > says function is undefined


Reply
 
Thread Tools Display Modes
  #1  
Old 12-04-2009, 03:15 PM
danny38 danny38 is offline
Newcomer
 
Join Date: Dec 2009
Posts: 1
Angry says function is undefined


Function NumbMonth(Table)

Count = 1
For i = 1 To 5 Step 1
Value = WorksheetFunction.VLookup(Date, Table, 4 + i)
Number(i) = WorksheetFunction.Month(Value)
If Number(i) > Number(i - 1) Then
Count = Count + 1
Next i


NumbMonth = Count


End Function

when I try to run this function it returns function is undefined?
Reply With Quote
  #2  
Old 12-05-2009, 03:03 AM
Qua's Avatar
Quasays function is undefined Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

What language are you writing in? It looks a bit like VBA which means you're in the wrong section on the forum. If you're actually writing vb.net code then there are several syntax errors in the code.
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
  #3  
Old 12-06-2009, 05:36 AM
Cerian Knight's Avatar
Cerian Knightsays function is undefined Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,191
Default

I moved this to VBA/Excel.

Which line does it stop on? You might try 'Application.WorksheetFunction', instead.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #4  
Old 12-06-2009, 07:36 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline
Out Of Office

Retired Moderator
* Expert *
 
Join Date: Mar 2005
Location: London, UK
Posts: 3,402
Default

Depending which type of module the code is located in, having a variable named Count can have undesirable consequences. Same goes for Number. They are both properties of various objects within the Office/VBA/Excel object libraries.

Add an Option Explicit statement to the top of the module and declare your Count and Number variables with different names.

That may (by chance) fix the problem. If it doesn't then please can you clarify which line throws the error and the environment you are coding in (Excel VBA/other VBA?/VB6/VB.Net) etc...
Reply With Quote
  #5  
Old 12-06-2009, 06:06 PM
all_add-in all_add-in is offline
Freshman
 
Join Date: Oct 2009
Location: Australia
Posts: 40
Default

To begin, you need to enter a return type in the function declaration statement (in addition to a byref/byval statement and variable type for the input variable).

Where are you trying to call the function from? Immediate window, excel cell (in the same workbook, or another?)?

Try adding a Public declaration to the function.

You are also missing the dim statements, and an End IF.

i.e.

Code:
Function NumbMonth(byval Table as range) as integer

Dim count as integer, i as integer
Dim value as variant
Dim number() as variant


Count = 1
For i = 1 To 5 Step 1
Value = WorksheetFunction.VLookup(Date, Table, 4 + i)
Number(i) = WorksheetFunction.Month(Value)
If Number(i) > Number(i - 1) Then
Count = Count + 1
End if
Next i


NumbMonth = Count


End Function

It also looks like you might not have been dimensioning the array correctly, but I might be wrong there.
Reply With Quote
Reply

Tags
function, undefined


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
says function is undefined
says function is undefined
says function is undefined says function is undefined
says function is undefined
says function is undefined
says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined says function is undefined
says function is undefined
says function is undefined
 
says function is undefined
says function is undefined
 
-->