A really simple newbie function bug?

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
%>
gekkomnaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lavinderCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lavinderCommented:
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
markhoyCommented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

whammyCommented:
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
GaryCommented:
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
whammyCommented:
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
FocusynCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.