convert a zero length string

S

seeker4

I am trying to convert a zero length string to an
integer. When I use cint(string) I receive a type
mismatch error. How can this be done? I am needing to
sum values in text boxes and some of them have no value.
I have tried textbox.text but then an error is given that
I cannot use a method unless the control has focus. Any
suggestions?

seeker4
 
D

Douglas J. Steele

A zero-length string is "", so you can't convert it to an integer. Are you
sure it's a ZLS, and not Null? Converting Null is easy: use the Nz function.
 
J

Joe Fallon

iif(myfield="",0,"")
--
Joe Fallon




Douglas J. Steele said:
A zero-length string is "", so you can't convert it to an integer. Are you
sure it's a ZLS, and not Null? Converting Null is easy: use the Nz function.
 
D

Douglas J. Steele

I think you meant iif(myfield="",0,myfield)

And AFAIK iif(Len(myfield)=0,0,myfield) is actually more efficient.
 
J

Joe Fallon

You get the idea. <g>
--
Joe Fallon




Douglas J. Steele said:
I think you meant iif(myfield="",0,myfield)

And AFAIK iif(Len(myfield)=0,0,myfield) is actually more efficient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top