473,508 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String functions run on empty string

I have a form in which several elements are expected to be all digits.
Some of those elements can be left empty, but if specified they must
be all digits. I have this Sub to edit them:

Sub NumEdit(ByRef Req, ByVal value, ByRef size, ByRef name, ByRef tag)
Dim allDigs
Set allDigs = new RegExp
allDigs.Pattern = "^\d+$"

If IsNull(value) Then
value = ""
Else
value = trim(value)
End If

If len(value) = 0 Then
If Req = false Then
Return
Else
AddMessage name & " must be supplied.", tag
End if
ElseIf size 0 And len(value) <size Then
AddMessage name & " must be " & size & " characters.", tag
ElseIf allDigs.test(value) = false Then
AddMessage name & " must be numeric.", tag
End If
End Sub
It's invoked by a line like this:
NumEdit false, Request.Form("zip"), 5, "Zip code", "zip"

In this case, the "zip" element is not required, but if present it
must be exactly five digits. (AddMessage stores an error message. It
works fine).

When zip is not given, the page blows up. I've experimented with
taking the values of various functions of Request.Form("zip"), with
the following results:

zip=
IsEmpty(zip)=False
IsNull(zip)=False
Len(zip)=0
Trim(zip)=
IsEmpty(Trim(zip))=
IsNull(Trim(zip))=
len(Trim(Zip))=

So Request.Form("zip") is not Empty, it's not Null, and its Len is 0.
But once I apply Trim to it, everything goes to heck. IsEmpty, IsNull,
and Len return nothing at all, and I get no error message.

What's happeneing?

--
Tim Slattery
MS MVP(DTS)
Sl********@bls.gov
http://members.cox.net/slatteryt
Jul 11 '07 #1
1 2583
Tim Slattery <Sl********@bls.govwrote:
>I have a form in which several elements are expected to be all digits.
Some of those elements can be left empty, but if specified they must
be all digits. I have this Sub to edit them:

Sub NumEdit(ByRef Req, ByVal value, ByRef size, ByRef name, ByRef tag)
Dim allDigs
Set allDigs = new RegExp
allDigs.Pattern = "^\d+$"

If IsNull(value) Then
value = ""
Else
value = trim(value)
End If

If len(value) = 0 Then
If Req = false Then
Return
Ugh! Now I find out that "Return" is not valid VBScript, I have to use
Exit Sub.

That makes the Sub work. I still don't understand the results I
reported lower down, but it doesn't matter much now.

--
Tim Slattery
MS MVP(DTS)
Sl********@bls.gov
http://members.cox.net/slatteryt
Jul 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
5818
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
19
10894
by: David Logan | last post by:
We need an additional function in the String class. We need the ability to suppress empty fields, so that we can more effectively parse. Right now, multiple whitespace characters create multiple...
8
4326
by: Duncan Winn | last post by:
I am new to VC++7. I am using a method GetPrivateProfileString that requires an LPTSTR. I have defined this as a: char * data_name; I am then trying to convert this to an LPOLESTR and I...
4
1420
by: AVL | last post by:
Hi, I read that to check for empty strings , comparing strings using String.Length == 0 is faster than String.Empty or "" . Is it true...? If so, how?
3
1405
by: scorpion53061 | last post by:
I have little hope of resolving this as I have had to contact outside help. But I thought I would post it here to see if anyone could add an idea or solution. 1. I have a form in a Class...
13
1512
by: Ivar | last post by:
Hi guys - So basically I am trying to implement a function that converts an int to a string, but it is not working for some reason - any thoughts? My function, intToStr, is shown below. I'm just...
35
5790
by: jacob navia | last post by:
Hi guys! I like C because is fun. So, I wrote this function for the lcc-win32 standard library: strrepl. I thought that with so many "C heads" around, maybe we could improve it in a...
6
7594
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
3
2040
by: digz | last post by:
This is a very simplified version of something I am trying to understand. The State object holds the strings and maps , and I pass a reference to State to the process Function which manipulates it...
9
4549
by: WebArchitect | last post by:
I have a text file. My text file contains lines with double quotes around it. I trying to code if a line has double quotes around it Then make it bold My code is below and it is not working....
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.