Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

A really simple newbie function bug?

Posted on 2003-03-15
7
Medium Priority
?
469 Views
Last Modified: 2012-06-22
hi,

I've written up this function, however there is a bug in it and I have NO idea what it is! I just started ASP yesterday so I still havn't quite got the hang of all the little things yet.

This is the error message I get from MSIE:
Error Type:
Microsoft VBScript compilation (0x800A03F4)
Expected 'If'
/functions/AddTextListOption.asp, line 57, column 4
End Function
---^

Ive looked at other sources and snippets, i cant seem to find where ive gone wrong.

Any help would be greatly appreciated!

GM

function follows...
~~~~~~~~~~


FUNCTION AddTextListOption(strValue, strAField, strBField)
SplitPoint = 50
Dim strCompiled
strCompiled = "<option value=""+ strValue +"">"
'
'SET THE RIGHT LENGTH FOR THE 1st HALF
'
If Len(strAField) > SplitPoint then 'cut it at SplitPoint
    strAField = left(strAField, SplitPoint)
Else If Len(strAField) < SplitPoint then 'pad it out with spaces till SplitPoint
    charcount = SplitPoint - Len(Value)

    for i = 1 to (charcount - 1)    
          paddingA = paddingA & " "
    next
    strAField = strAField & paddingA
End If
'
'NOW THE SECOND HALF
'
If Len(strBField) > SplitPoint then 'cut it at SplitPoint
    strBField = left(strBField, SplitPoint)
Else If Len(strBField) < SplitPoint then 'pad it out with spaces till SplitPoint
    charcount = SplitPoint - Len(Value)

    for i = 1 to (charcount - 1)    
          paddingB = paddingB & " "
    next
    strBField = strBField & paddingB
End If

strCompiled = strDesc & strAField & strBField & "</option>" 'the complete option string

AddTextListOption = strCompiled

End Function
%>
0
Comment
Question by:gekkomna
7 Comments
 
LVL 7

Accepted Solution

by:
lavinder earned 300 total points
ID: 8142303
hi
 try this

FUNCTION AddTextListOption(strValue, strAField, strBField)
 Dim strCompiled

 SplitPoint = 50
 strCompiled = "<option value=""+ strValue +"">"

 '
 'SET THE RIGHT LENGTH FOR THE 1st HALF
 '
 If Len(strAField) > SplitPoint then 'cut it at SplitPoint
  strAField = left(strAField, SplitPoint)
 ElseIf Len(strAField) < SplitPoint then
  charcount = SplitPoint - Len(Value)
  for i = 1 to (charcount - 1)    
   paddingA = paddingA & " "
  next
  strAField = strAField & paddingA
 End If

 '
 'NOW THE SECOND HALF
 '
 If Len(strBField) > SplitPoint then 'cut it at SplitPoint
  strBField = left(strBField, SplitPoint)
 ElseIf Len(strBField) < SplitPoint then
  charcount = SplitPoint - Len(Value)
  for i = 1 to (charcount - 1)    
   paddingB = paddingB & " "
  next
  strBField = strBField & paddingB
 End If

 strCompiled = strDesc & strAField & strBField & "</option>" 'the complete option string

 AddTextListOption = strCompiled

End Function
0
 
LVL 7

Expert Comment

by:lavinder
ID: 8142306
before learning asp, first learn and use vbscript, (read the documentation) and tutorials. for asp tutorials, you can try following sites:

http://www.asp101.com
http://www.aspin.com
http://www.aspfaqs.com
http://www.4guysfromrolla.com

 feel free to post your problems at EE.

happy programming !!
0
 
LVL 7

Expert Comment

by:markhoy
ID: 8143273
Your error msg means a tag is missing

if <condition> then
do stuff

else

do something else

end if

also

www.w3schools.com
www.learnasp.com
www.aspfaqs.com

and,

http://msdn.microsoft.com/workshop/server/asp/asptips.asp: 25+ ASP tips to improve performance and style
4GuysFromRolla.com ASP coding tips, articles and examples.
http://www.kamath.com/ Active Server Corner articles, tutorials and free ASP components.
http://www.activeserverpages.com/ ActiveServerPages.com articles, tutorials and more.
ASP 101 samples, articles, resources and information for developers.
ASP Alliance.com a collection of ASP components, articles and tutorials.
ASPCode.net free ASP applications and code snippets.
ASP-Help.Com ASP resources, reviews and tutorials.
http://www.aspin.com/ ASP Resource Index a collection of ASP resources.
http://asp.superexpert.com/ ASP Super Experts answers to ASP questions, articles, jobs, links and software.
http://www.tcp-ip.com/ASP Toolbox directory for ASP application, components and tutorials.
http://www.asptown.com/ ASP Town ASP resource with scripts and articles, components, guides and software.
http://www.aspwatch.com/index.asp ASPwatch.com articles on ASP scripting, database, components and integration.
FindTutorial.com free ASP tutorials.
Haneng.com ASP lessons.
LearnASP.com tutorials and lessons on how to use ASP.
http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/iisref/comp275c.htm Microsoft ASP Component Developer Samples
ProgrammersResource.com ASP information, components and scripts.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:whammy
ID: 8146332
As lavinder pointed out in his original post, the initial mistake (the one that's causing that error) is you used:

Else If

in VBSCript that's supposed to be:

ElseIf (one word)
0
 
LVL 58

Expert Comment

by:Gary
ID: 9349751
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by lavinder

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0
 
LVL 4

Expert Comment

by:whammy
ID: 9409964
Yay...

BTW, GaryC123, I think a good answer to all of these unresolved posts is to revoke the user's membership. After all, they signed up for this stuff, read the TOS, etc.

If they can't even answer their own post, their membership should be automatically revoked with a cleanup question, since it wastes my time, the other people who answered the questions' time, and your time.

Please forward this on for consideration - this is a PLAGUE. ;o)
0
 
LVL 7

Expert Comment

by:Focusyn
ID: 23096713
If it makes you feel better whammy, I just found your comment extremely useful...almost 6 years later.  I've been coding mostly VS 2008 and 2003 lately, and was just trying to reconfigure a bunch of legacy apps for an NT Server migration to this century.  Couldn't figure out why I was getting the expected IF error.  I know legacy has to be ElseIf, and yet in spite of that I didn't recognize it there the first 100 times I read the code.  So thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

578 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