PC Review


Reply
Thread Tools Rate Thread

Dim xxx As String & IF?

 
 
=?Utf-8?B?UmF5cG9ydGluZ01vbmtleQ==?=
Guest
Posts: n/a
 
      3rd Oct 2007
I am using CDO Mail to distribute reports. My script has been wroking great
and sends out multiple reports, however I now have to setup more that one
distribution list...

I already have logic that identifies what reports are being sent and want to
use something similar to choose the distro list, but I don't know if using an
IF statement is valid when defining a variable.

Here's a snippet of the code I am trying to use:

Dim SCType As String
SCType = sh.Range("K6")

Dim Distro As String
If SCType = "WFSCScheduler" Then
Distro = "(E-Mail Removed)"
Else: Distro = "(E-Mail Removed)"
End
End If

Yeah, I suppose I could put a formula in the sheet and define the distro
that way, but I really hate to clutter up my sheets... Also, I may need to
build additional distros, so additional Else/IF Statements may be necessary.

What am I doing wrong?

Thanks!
Ray

 
Reply With Quote
 
 
 
 
George Nicholson
Guest
Posts: n/a
 
      3rd Oct 2007
1) Take out the 'End' statement. That stops all code & resets all variables.
Do that and what you have will probably work fine.

2) If you expect you will be adding additional conditions, consider using a
Select Case structure rather than a If..Then..ElseIf: Unless you have a
simple either/or condition, I find it much easier to read, debug & maintain.

Select Case SCType
Case "WFSCScheduler"
Distro = "(E-Mail Removed)"
Case "SomeNewValue", "NewWFSC"
Distro = "(E-Mail Removed)"
Case Else
Distro = "(E-Mail Removed)"
End Select


HTH,

"RayportingMonkey" <(E-Mail Removed)> wrote in
message news:3390C746-6882-4E06-B14C-(E-Mail Removed)...
>I am using CDO Mail to distribute reports. My script has been wroking great
> and sends out multiple reports, however I now have to setup more that one
> distribution list...
>
> I already have logic that identifies what reports are being sent and want
> to
> use something similar to choose the distro list, but I don't know if using
> an
> IF statement is valid when defining a variable.
>
> Here's a snippet of the code I am trying to use:
>
> Dim SCType As String
> SCType = sh.Range("K6")
>
> Dim Distro As String
> If SCType = "WFSCScheduler" Then
> Distro = "(E-Mail Removed)"
> Else: Distro = "(E-Mail Removed)"
> End
> End If
>
> Yeah, I suppose I could put a formula in the sheet and define the distro
> that way, but I really hate to clutter up my sheets... Also, I may need to
> build additional distros, so additional Else/IF Statements may be
> necessary.
>
> What am I doing wrong?
>
> Thanks!
> Ray
>



 
Reply With Quote
 
=?Utf-8?B?UmF5cG9ydGluZ01vbmtleQ==?=
Guest
Posts: n/a
 
      3rd Oct 2007
I opted for the Select Case method and it worked great - Thanks!

"George Nicholson" wrote:

> 1) Take out the 'End' statement. That stops all code & resets all variables.
> Do that and what you have will probably work fine.
>
> 2) If you expect you will be adding additional conditions, consider using a
> Select Case structure rather than a If..Then..ElseIf: Unless you have a
> simple either/or condition, I find it much easier to read, debug & maintain.
>
> Select Case SCType
> Case "WFSCScheduler"
> Distro = "(E-Mail Removed)"
> Case "SomeNewValue", "NewWFSC"
> Distro = "(E-Mail Removed)"
> Case Else
> Distro = "(E-Mail Removed)"
> End Select
>
>
> HTH,
>
> "RayportingMonkey" <(E-Mail Removed)> wrote in
> message news:3390C746-6882-4E06-B14C-(E-Mail Removed)...
> >I am using CDO Mail to distribute reports. My script has been wroking great
> > and sends out multiple reports, however I now have to setup more that one
> > distribution list...
> >
> > I already have logic that identifies what reports are being sent and want
> > to
> > use something similar to choose the distro list, but I don't know if using
> > an
> > IF statement is valid when defining a variable.
> >
> > Here's a snippet of the code I am trying to use:
> >
> > Dim SCType As String
> > SCType = sh.Range("K6")
> >
> > Dim Distro As String
> > If SCType = "WFSCScheduler" Then
> > Distro = "(E-Mail Removed)"
> > Else: Distro = "(E-Mail Removed)"
> > End
> > End If
> >
> > Yeah, I suppose I could put a formula in the sheet and define the distro
> > that way, but I really hate to clutter up my sheets... Also, I may need to
> > build additional distros, so additional Else/IF Statements may be
> > necessary.
> >
> > What am I doing wrong?
> >
> > Thanks!
> > Ray
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make two references to one string that stay refered to the same string reguardless of the changing value in the string? Daniel Microsoft Dot NET 7 12th Nov 2004 09:08 AM
how to make two references to one string that stay refered to the same string reguardless of the changing value in the string? Daniel Microsoft C# .NET 10 3rd Nov 2004 03:26 PM
Cannot create an object of type 'System.String[]' from its string representation 'String[] Array' for the 'Options' property. Hessam Microsoft C# .NET 0 8th Aug 2003 09:45 AM
Re: Converting a string to a string that contains the ASCII values of each letter in the origional string Mikael Jansson Microsoft C# .NET 0 31st Jul 2003 08:42 PM
Re: Converting a string to a string that contains the ASCII values of each letter in the origional string Frank Oquendo Microsoft C# .NET 0 31st Jul 2003 08:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:10 PM.