Solved VB to VBS Scripting.

Microsoft Windows vista home premium w/s...
September 18, 2012 at 17:05:38
Specs: Windows 7
I need to change the following command into VB Script.
Can anyone help please ?

Public Function CleanUp(ADInfo As String) As String
Dim ADArr() As String
Dim Temp As String
Dim First As Boolean

First = True
ADArr() = Split(ADInfo, ",")
For i = UBound(ADArr) To LBound(ADArr) Step -1
If InStr(1, ADArr(i), "OU") <> 0 Then
If First = True Then
Temp = Right(ADArr(i), Len(ADArr(i)) - 3)
First = False
Else
Temp = Temp & "/" & Right(ADArr(i), Len(ADArr(i)) - 3)
End If
End If
Next i
CleanUp = Temp
End Function


See More: VB to VBS Scripting.

Report •


#1
September 18, 2012 at 19:20:24
✔ Best Answer
Public Function CleanUp(ADInfo)
First = True
ADArr = Split(ADInfo, ",")
For i = UBound(ADArr) To LBound(ADArr) Step -1
If InStr(1, ADArr(i), "OU") <> 0 Then
If First = True Then
Temp = Right(ADArr(i), Len(ADArr(i)) - 3)
First = False
Else
Temp = Temp & "/" & Right(ADArr(i), Len(ADArr(i)) - 3)
End If
End If
Next
CleanUp = Temp
End Function
'=======
although I doubt you really want: right(adarr(i),len(adarr(i))-3))
If you want the right 3 bytes of the string, you just need this: right(adarr(i),3)
but i might be mistaken. Anyway, this ran and produced output with no errors.

Report •

#2
September 18, 2012 at 19:59:58
I assume he wants all but the last 3 characters, hence the len(str) - 3.

How To Ask Questions The Smart Way


Report •

#3
September 18, 2012 at 20:11:20
LolHa! you mean all but the first three? I guess "mid(adarr(i),4)" might simplify that confusion somewhat. ;-)

Report •

Related Solutions

#4
September 18, 2012 at 20:57:08
That worked perfectly, thank you very much.
I have +1 your answer.

Report •


Ask Question