?
Solved

A really simple newbie function bug?

Posted on 2003-03-15
7
Medium Priority
?
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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