|
-
Aug 13th, 2002, 07:37 AM
#1
Thread Starter
Fanatic Member
Remove a empty value from text boxes
I have three variables, var1, var2 and var3.. In this function I am taking the three values and shuffling them.. MY QUESTION is sometimes one of the variables will be empty and will not have a value, is there a way to take only the variables that are not empty and then I can plug them into my formula...
Var1 = request.form("text1")
Var2 = request.form("text2")
Var3 = request.form("text3")
sNums = Var1 & "," & Var2 & "," & Var3
function Jumble(ByVal sNumbers, ByVal sSplit, ByVal sJoin)
dim aN, sTemp, ub, lb, i1, i2
aN = split(sNumbers,sSplit)
Randomize
lb = lbound(aN)
ub = ubound(aN)
for i = lb to ub
i1 = Int((ub-lb+1)*RND + lb)
i2 = Int((ub-lb+1)*RND + lb)
sTemp = aN(i1)
aN(i1) = aN(i2)
aN(i2) = sTemp
next
Jumble = join(aN,sJoin)
end function
sNums = Jumble(sNums,",",",")
sNums = split(sNums,",")
for i = 0 to ubound(sNums)
'Response.Write "<input type=text name=text" & i + 1 & " value=" & sNums(i) & "><br>"
next
-
Aug 21st, 2002, 12:47 PM
#2
Junior Member
This is very sloppy, but you'll get the idea:
Var1 = request.form("text1")
Var2 = request.form("text2")
Var3 = request.form("text3")
if len(Var1 ) > 0 then
sNums = Var1 & ","
end if
if len(Var2 ) > 0 then
sNums = sNums & Var2 & ","
end if
if len(Var3 ) > 0 then
sNums = Var3 & ","
end if
'now strip off the ending comma, if you don't want it
if len(sNums ) > 0 then
sNums = left$(sNums, len(sNums) -1)
end if
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|