Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with Valid Event coding

Status
Not open for further replies.

shenlon

Programmer
Jul 9, 2003
47
US
OK, first off I want to declare that I am VERY wet-behind-the-ears here with VFP. I have taken courses for C++ and Java, but that is the extent of my programming knowledge. Anyways, back to the problem at hand. I have a form, and one of the text boxes on this form is called SERIAL_NO1 and is used to store VIN numbers for cars. Right now, I am just trying to write the code that will check the 9th position of the string and if it does not equal a certain number/letter (8 in this case) then I want to display an error. Here's the code that I have written:

cVinString=ThisForm.SERIAL_NO1
cMessageText='VIN error'
cMessageTitle='VIN Check'
nDialogType=48
IF SUBSTR(cVinString,9,1) != '8'
MESSAGEBOX(cMessageText,nDialogType,cMessageTitle)
ENDIF

The error message I get is that there is "Function argument value, type, or count is invalid." The SERIAL_NO1 field is tied to a database, but if possible, the check needs to be done from the textbox itself because users will be adding new cars through this page, and new cars aren't in the database yet. Plesae help me out, or atleast try to explain to me what has gone wrong.


*****************************************
OK, after finally figuring out how to read through and actually get some information from the Debugger, I have concluded that cVinString is being stored in memory as an object, not a Character-type, so what do I need to do to change that? Hopefully this helps some
 
Shenlon,

First, welcome to Visual Foxpro. It can seem a bit daunting at first, but it is worth persevering with. Judging by what you have done so far, it looks like you are off to a good start.

ASs Mike Gagnon has pointed out, the reason for your error message was that you should have included .value in the reference to the SERIAL_NO1 control.

I am a Visual Foxpro trainer, and I can tell you that that particular mistake is by far the most common mistake that beginners make. Almost everyone who comes on my courses forgets to add .value sometimes. So don't feel bad about it. It is a very natual error.

Mike




Mike Lewis
Edinburgh, Scotland
 
Thank you guys so much, that problem was really bugging me and I could not figure out what I was missing.
 
Sorry. I said As Mike Gagnon has pointed out ... . that should be Jim Starr of course. I am so accustomed to agreeing with everything Mike G says <g>, that my fingers types his name automatically.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top