Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
|
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 24th, 2003, 07:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default Concatenation question, please

I have a line of code where I am trying to append the actual TEXT of the day name at the end of a column where I am displaying the contents of the DATETIME. So that my column per records will look like:

DATETIME
Monday

or

DATETIME
Tuesday, etc.

I am having syntax problems and was wondering if anyone could help me by telling me where my problem is:

strWebLogActivityTable = strWebLogActivityTable & "<td align='left' bgcolor='#FFFF00' width='100'><b>" & trim(rs("access_date")) & "</b><br>"

If strday = 1 Then
 "<b>Monday</b>"
Elseif strday = 2 Then
 "<b>Tuesday</b>"
Elseif strday = 3 Then
 "<b>Wednesday</b>"
Elseif strday = 4 Then
 "<b>Thursday</b>"
Elseif strday = 5 Then
 "<b>Friday</b>"
Elseif strday = 6 Then
 "<b>Saturday</b>" & _
Elseif strday = 7 Then
 "<b>Sunday</b>" & _
strWebLogActivityTable = strWebLogActivityTable & "</td>"
Reply With Quote
  #2 (permalink)  
Old July 24th, 2003, 08:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this instead of your multiple If/ElseIf statements:
Code:
strWebLogActivityTable = strWebLogActivityTable & "<td align='left' bgcolor='#FFFF00' width='100'><b>" & trim(rs("access_date")) & "</b><br>"

strWebLogActivityTable = strWebLogActivityTable & _
    WeekDayName(Weekday(rs("access_date"))) & _
    "</td>"
Reply With Quote
  #3 (permalink)  
Old July 24th, 2003, 08:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default



Thanks for the response. However, I am still getting a different column for the day it is not appending to the DATETIME column. Any suggestions?

Thanks.

Quote:
quote:Originally posted by pgtips
 Try this instead of your multiple If/ElseIf statements:
Code:
strWebLogActivityTable = strWebLogActivityTable & "<td align='left' bgcolor='#FFFF00' width='100'><b>" & trim(rs("access_date")) & "</b><br>"

strWebLogActivityTable = strWebLogActivityTable & _
    WeekDayName(Weekday(rs("access_date"))) & _
    "</td>"
Reply With Quote
  #4 (permalink)  
Old July 24th, 2003, 08:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
I am still getting a different column for the day
it is not appending to the DATETIME column. Any suggestions?
Sorry but I don't understand what you're saying here.
Can you post the HTML that is being generated by your ASP page
(or maybe only the relevant portion if its large), along with
a description of how you would like it to appear?
Reply With Quote
  #5 (permalink)  
Old July 24th, 2003, 09:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default

I got the code working. It was my bad, sorry about that.

Thanks again for all your help!!

Quote:
quote:Originally posted by pgtips
 
Quote:
quote:
Quote:
I am still getting a different column for the day
it is not appending to the DATETIME column. Any suggestions?
Sorry but I don't understand what you're saying here.
Can you post the HTML that is being generated by your ASP page
(or maybe only the relevant portion if its large), along with
a description of how you would like it to appear?
Reply With Quote
  #6 (permalink)  
Old July 24th, 2003, 09:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
I got the code working. It was my bad, sorry about that.
Hey, no problem. Glad its working for you now :)
Reply With Quote
  #7 (permalink)  
Old April 22nd, 2009, 01:51 AM
Authorized User
 
Join Date: Apr 2009
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Concatenation question, please

In your original Code sequence, the last "ElseIf" should be "Else".

"ElseIf" is in an additional "Else" Statement.

"Else" is an additional "If...Then" Statement.

Also, "Else" acts as an END Statement for "If...Then...ElseIf" Sequences.
Reply With Quote
  #8 (permalink)  
Old April 22nd, 2009, 06:09 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

*ANOTHER* WRONG ANSWER.

ELSEIF is a special keyword in VBScript (and in VB6 and in VB5 and in VB.NET and...).

It is *NOT* the same thing as Else If (note the space).

The code as given, with Elseif *IS CORRECT*.

Oh, and now you are answering SIX year old posts.
Reply With Quote
  #9 (permalink)  
Old April 30th, 2009, 08:42 PM
Authorized User
 
Join Date: Apr 2009
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Post

ONE:
I didn't know that this Topic Thread was 6 years old.

TWO:
For GW-BASIC "ElseIf" has to be "Else If"; but, for VBScript, "ElseIf" is correct.

My Statement that the last "ElseIf" in the "If...Then...ElseIf" Loop needs to be "Else".

Look on Page 21 in VBScript 3rd Edition. The Programming Code for Function PromptUserName uses "ElseIf" not "Else If".

Also "ElseIf" does work in my VBScript Codes on my COMPAQ ARMADA 1750 Laptop with Windows 2000 Profressional.

THREE:
That same Function PromptUserName Code has "Else" as the last "ElseIf" Option in the "If...Then...ElseIf" Loop.

THEREFORE...YOU ARE WRONG...AND I AM CORRECT.

Of course...I am putting "Else" and "ElseIf", and "Else If" in quotes because I am talking about those specific word spellings; and, those quotation marks don't belong in any Code.

Just to be sure, you have mis-read my meaning in my original Reply.

Last edited by Tandy1000SL GW-BASIC; April 30th, 2009 at 08:45 PM..
Reply With Quote
  #10 (permalink)  
Old May 1st, 2009, 05:15 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

It's truly amazing how badly you manage to misread documentation. Either that, or the book you are learning from needs to thrown in the trash. I've never seen that book; I learned VBScript from reading Microsoft's documentation.

Yes, you *CAN* use an ELSE as the last "catch all" condition in an "IF...ELSEIF...ELSEIF...ELSE...END IF" sequence. But you do *NOT* HAVE TO! It *IS* optional.

I'm going to bet you won't believe me without proof, so try this VBS file, yourself:
Code:
MsgBox "First iteration..."

For i = 1 To 4
    If i > 3 Then
        MsgBox "i is " & i & " which is greater than 3"
    Elseif i > 2 Then
        MsgBox "i is " & i & " which is greater than 2"
    Else
        MsgBox "is is " & i
    End If
Next

MsgBox "Now starting the second iteration..."

For i = 1 To 4
    If i > 3 Then
        MsgBox "i is " & i & " which is greater than 3"
    Elseif i > 2 Then
        MsgBox "i is " & i & " which is greater than 2"
    End If
Next
Oh...and I don't really care what GW-BASIC does or does not or did or did not accept. I wrote 4 different BASIC interpreters during my career, and every one of them did *something* differently than VBScript does and they are all irrelevant today.
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
String concatenation query. AjayLuthria XSLT 2 March 14th, 2007 11:55 AM
Aggregate Concatenation 12th_Man SQL Language 4 January 10th, 2006 03:26 PM
Concatenation of fields JpJoe Access 8 April 8th, 2005 01:32 AM
string concatenation nulogix PHP How-To 1 June 24th, 2004 06:17 AM
string concatenation matt_99 Access VBA 2 January 17th, 2004 09:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.