Thread: vbscript help
View Single Post
Old 2008-11-27, 03:02   #19
WraithX
 
WraithX's Avatar
 
Mar 2006

47210 Posts
Default

Quote:
Originally Posted by IronBits View Post
Ok, so this works

Const strTeams = "",Free-DC,AMDUsers,ArsTechnica,.....


if Left(str_CurrentLine,5) = "user=" Then
MyArray = Split(str_CurrentLine,"=",-1,1)
Team_Name = MyArray(1)
arrMyTeamName = Split(Team_Name,"_",-1,1)
StringPos = InStr(1, strTeams, arrMyTeamName(0), vbTextCompare)
if StringPOS > 0 Then
UserName = arrMyTeamName(1)
Else
UserName = Team_Name
End If

Maybe one of you can find a cleaner way to achieve the same thing?
Well, If I understand what you are trying to do, then maybe the following would work for you:

Code:
If Left(str_CurrentLine,5) = "user=" Then
  MyArray = Split(str_CurrentLine,"=",-1,1)
  Team_Name = MyArray(1)

  If InStr(1, Team_Name, "Team_", 1) > 0 Then
    UserName = Right(Team_Name, Len(Team_Name)-5)
  Else
    UserName = Team_Name
  End If
End If
One place I've found to be a valuable resource for vbscript is here:
http://www.w3schools.com/VBscript/vb..._functions.asp
WraithX is offline   Reply With Quote