Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Function Trouble

Posted on 1998-11-06
Medium Priority
175 Views
I have a function that I am trying to call and for some reason I can't get it to work.  The function is not complete yet but here's what I have so far:

Function Validate(Entered As String, TypeEntered As Integer, FieldName As String)

If TypeEntered = 0 Then
If Entered = "" Then
Trim (Entered)
Entered = InputBox("There must be an entry in the " + FieldName + " field.  Please enter it below.")
End If
End If

End Function

Every time I try to call the function gives me the error:
Expected:=
I don't understand.  The way I tryed to call it is:

Validate(txtFirstName.text, 0, "First Name")

HELP!!!!!
0
Question by:thorner
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 3

Accepted Solution

fguerreiro_inix earned 100 total points
ID: 1443589
A function should return a value.

You must assign a variable of the same type of the function's returned value.

something = Validate(txtFirstName.text, 0, "First Name")

Hope this helps
Regards
0

Author Comment

ID: 1443590
0

LVL 3

Expert Comment

ID: 1443591

Function Validate(Entered As String, TypeEntered As _
integer,FieldName As String)as boolean

Validate= true

If TypeEntered = 0 Then
If Entered = "" Then
Trim (Entered)
Entered = InputBox("There must be an entry in the _
+ FieldName + " field.  Please enter it below.")
Validate= false
End If
End If

End Function

You should say what kind of value the function returns.

Function blabla(aaa As String, bbb As integer) as boobean

and the function blabla returns a boolean. Inside the function you must assign the value you want to return (true or false).
If you don't specify the type of the return value it will return a variant.

Hope this helps
Regards

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
###### Suggested Courses
Course of the Month9 days, 1 hour left to enroll