Login | |
|
 |
RE: Scratching my head for hours trying to work this out - 12/13/2006 3:32:27 AM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
|
I thought about it some more and Join() would not be best. Here is an example that would do what you want I believe: Option Explicit Dim strResponse Dim strResult Dim arrResponses(2) arrResponses(0) = InputBox("Enter One") arrResponses(1) = InputBox("Enter Two") arrResponses(2) = InputBox("Enter Three") For Each strResponse In arrResponses If strResponse <> "" Then strResult = strResult & strResponse & "-" End If Next If strResult <> "" Then strResult = Left(strResult, Len(strResult)-1) WScript.Echo strResult
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/13/2006 4:19:44 AM
|
|
 |
|
| |
dm_4ever
Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
There are a few If statements where you don't really need to use the "else" in. i.e. If re2.Test(strNewFullName) then strNewFullName = re2.replace(strNewFullName, " ") Else End If you can simply have it as If re2.Test(strNewFullName) then strNewFullName = re2.replace(strNewFullName, " ") End If As for the CHM, you normally get that error when you try to view it off a site or a network share. It should work if you download it to your local drive and launch it from there. There is also a registry tweak you can make to fix this. see: http://support.microsoft.com/kb/896054
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/13/2006 6:13:10 AM
|
|
 |
|
| |
dm_4ever
Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
Yes, you do not need the "else" if you don't have anything following it other than the "end if". In fact, if your "IF" statement is simple enough you do not even need the "end if". simple example. As you can see the whole IF statement is on one line without an "else" or "end if" and the value of str was changed because it matched the criteria I was looking for. Dim str str = "Just some text." If InStr(str, "some") Then str = "Something else" WScript.Echo str
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/13/2006 6:56:38 AM
|
|
 |
|
| |
Country73
Posts: 735
Score: 10
Status: offline
|
Here's some help on viewing your CHM file: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions MaxAllowedZone = dword 1
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/13/2006 7:09:35 AM
|
|
 |
|
| |
dm_4ever
Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
You would absolutely use the "end if" if you want several things to happen and putting it on one line simply wouldn't make sense. on the same lines of the previous example. Dim str str = "Just some text." If InStr(str, "some") Then str = "Something else" WScript.Echo str testsub WScript.Echo testfunction(str) End If Sub testsub WScript.Echo "test sub" End Sub Function testfunction(strIn) testfunction = UCase(strIn) End Function
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/13/2006 8:04:56 AM
|
|
 |
|
| |
dm_4ever
Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
You are absolutely right Digital. I like using the ":" on certain things, but it looks a lot neater and easier to read when you have them on seperate lines. It is a good thing to show though.
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/14/2006 12:49:18 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
No doubt. It makes things nicer here and there, but - as I think I showed - it *can* be taken to extremes!
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: Scratching my head for hours trying to work this out - 12/14/2006 1:20:02 AM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
|
For Each strResponse In arrResponses If strResponse <> "" Then strResult = strResult & strResponse & "-" End If Next This code is treating the array as a collection. Behind the scenes, the compiler is really doing this: For i = 0 To UBound(arrResponses) strResponse = arrResponses(i) If strResponse <> "" Then strResult = strResult & strResponse & "-" End If Next
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|