?
Solved

need help with code

Posted on 2003-03-02
5
Medium Priority
?
144 Views
Last Modified: 2010-05-01
Using vb4 I need help with the following:

In the "General instructions" I have the following code.

Public Function isvalid(ByVal str As String) As Boolean
isvalid = (UCase(str) Like "[a-z][a-z][a-z]#[a-z]##[a-z][a-z]#[a-z]#")
End Function

I am trying to match a pattern for a user entered serial number.
(a-z) = any letter and # = any number. But the letters and the numbers entered MUST match the pattern above.

In the Form command1 is the following:


Private Sub Command1_Click()
abc = Val(Form1.Text1.Text)
If abc = isvalid Then
MsgBox "yea", ib
Else: MsgBox "no", ib
End sub

I get the following error msg even before the prog starts

"ambiguous name detected : isvalid"

Help please
0
Comment
Question by:hjaycox
[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
  • Learn & ask questions
5 Comments
 
LVL 7

Expert Comment

by:MrNed
ID: 8054621
Call the function with a parameter:

If isvalid(abc) Then
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8054685
>>"ambiguous name detected : isvalid"
Try find the function 'isvalid', it seems to be appear more that 1 place in your code, leave only 1 function that works for your application.
0
 
LVL 3

Expert Comment

by:DocM
ID: 8055142
This syntax seems OK:

Public Function isvalid(ByVal str As String) As Boolean
isvalid = (LCase(str) Like "[a-z][a-z][a-z]#[a-z]##[a-z][a-z]#[a-z]#")
End Function

Private Sub Command1_Click()
abc = Form1.Text1.Text
If isvalid(abc) Then
MsgBox "yea"
Else: MsgBox "no"
End If
End Sub
0
 

Author Comment

by:hjaycox
ID: 8061329
DocM

Thank you for your help. With your code, I no longer have that error , But no matter what I type into the text box, correct pattern or not gets me .....Else: MsgBox "no"

Am I missing something????????????
0
 
LVL 3

Accepted Solution

by:
DocM earned 800 total points
ID: 8061395
A valid entry would be, for example : abc9d99ef9g9

Public Function isvalid(ByVal str As String) As Boolean
'Expected entry, for example,  abc9d99ef9g9
isvalid = (LCase(str) Like "[a-z][a-z][a-z]#[a-z]##[a-z][a-z]#[a-z]#")
End Function

Private Sub Command1_Click()
abc = Form1.Text1.Text
If isvalid(abc) Then
MsgBox "yea"
Else: MsgBox "no"
End If
End Sub
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question