Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  2008  Scripting  Games  Advanced  VBScript  Event  7  

 Content of 2008 Scripting Games Advanced VBScript Event 7.vbs
MD5 Hash: 05AD9FE07BD733B22DE462AB148AA00E
' This is my Solution for the Scripting Games 2008
' For more Information look at
' http://www.microsoft.com/technet/scriptcenter/funzone/games/games08.mspx

Option Explicit

Dim iCount, iCount2
Dim iCountRnd : iCountRnd = 0
Dim iRandom
Dim strResultGames

Dim arrTeams(5)
Dim bRandome
Dim arrGamesRandom(14,1)

arrTeams(0) = "A"
arrTeams(1) = "B"
arrTeams(2) = "C"
arrTeams(3) = "D"
arrTeams(4) = "E"
arrTeams(5) = "F"

For iCount = 0 To Ubound(arrTeams)

For iCount2 = iCount To Ubound(arrTeams) -1

iRandom = RadomeInt(100)
If IsArray(arrGamesRandom) then

bRandome = CheckRandome(arrGamesRandom,iRandom)

Do while bRandome = true
iRandom = RadomeInt(100)
bRandome = CheckRandome(arrGamesRandom,iRandom)
Loop

End if

arrGamesRandom(iCountRnd,0) = arrTeams(iCount) & " vs. " & _
arrTeams(iCount2 +1)

arrGamesRandom(iCountRnd,1) = iRandom
iCountRnd = iCountRnd +1

Next
Next

Call SortArrayDim(arrGamesRandom, "ASC")

For iCount = 0 to UBound(arrGamesRandom)

strResultGames = strResultGames & arrGamesRandom(iCount,0) & vbcrlf

Next

wscript.echo strResultGames


'---------------------------
Private Function RadomeInt(iMax)

Randomize
RadomeInt = Int((iMax * Rnd) + 1)

End Function

'---------------------------
Private Function CheckRandome(arrSource, iRandom)

Dim iRet : iRet = false

Dim iCount3

For iCount3 = 0 to UBound(arrSource)
If arrSource(iCount3,1) = iRandom then
iRet = true
Exit For
End if
Next

CheckRandome = iRet

End Function

'---------------------------
Private Function SortArrayDim(SourceArray, strSortTyp)

Dim Sorted, iCount, Temp, Temp2

Sorted = False

Do While Not Sorted
Sorted = True

For iCount = 0 To UBound(SourceArray) - 1

Select Case UCase(strSortTyp)

Case "ASC"

If UCase(SourceArray(iCount, 1)) > UCase(SourceArray(iCount + 1, 1)) Then
Temp = SourceArray(iCount + 1, 0)
Temp2 = SourceArray(iCount + 1, 1)
SourceArray(iCount + 1, 0) = SourceArray(iCount, 0)
SourceArray(iCount + 1, 1) = SourceArray(iCount, 1)
SourceArray(iCount, 0) = Temp
SourceArray(iCount, 1) = Temp2
Sorted = False
End If

Case "DESC"

If UCase(SourceArray(iCount, 1)) < UCase(SourceArray(iCount + 1, 1)) Then
Temp = SourceArray(iCount + 1, 0)
Temp2 = SourceArray(iCount + 1, 1)
SourceArray(iCount + 1, 0) = SourceArray(iCount, 0)
SourceArray(iCount + 1, 1) = SourceArray(iCount, 1)
SourceArray(iCount, 0) = Temp
SourceArray(iCount, 1) = Temp2
Sorted = False
End If

End Select

Next

Loop

End Function


   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a