# how can i simplify this code

Page 1 of 1

## 1 Replies - 899 Views - Last Post: 07 April 2008 - 05:00 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=48418&amp;s=52cae64c8484cb9fd70995ef8450c16a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sherrill

• New D.I.C Head

Reputation: 0
• Posts: 9
• Joined: 27-March 08

# how can i simplify this code

Posted 07 April 2008 - 11:15 AM

how can i simplify this code and clean it up?
this is a loop to calculate which numbers match

```' Calculate the numbers that match.
Dim intCount As Integer                 ' Loop counter
Dim intWin As Integer = 0               ' Digits match counter
Dim intMatching As Integer = -1         ' All numbers match counter

'Sets the Booleans and initializes.
Dim intMatch1 As Boolean = False
Dim intMatch2 As Boolean = False
Dim intMatch3 As Boolean = False
Dim intMatch4 As Boolean = False
Dim intMatch5 As Boolean = False

' Looks for matching numbers
For intCount = 0 To intMAX_VALUES
If intDigits(0) = intNumber(intCount) And intMatch1 = False And intMatching <> intCount Then
intWin = intWin + 1
intMatch1 = True
intMatching = intCount
End If
If intDigits(1) = intNumber(intCount) And intMatch2 = False And intMatching <> intCount Then
intWin = intWin + 1
intMatch2 = True
intMatching = intCount
End If
If intDigits(2) = intNumber(intCount) And intMatch3 = False And intMatching <> intCount Then
intWin = intWin + 1
intMatch3 = True
intMatching = intCount
End If
If intDigits(3) = intNumber(intCount) And intMatch4 = False And intMatching <> intCount Then
intWin = intWin + 1
intMatch4 = True
intMatching = intCount

End If
If intDigits(4) = intNumber(intCount) And intMatch5 = False And intMatching <> intCount Then
intWin = intWin + 1
intMatch5 = True
intMatching = intCount
End If
Next

```

*edit: Please use code tags in the future, thanks!

This post has been edited by Martyr2: 07 April 2008 - 11:29 AM

Is This A Good Question/Topic? 0

## Replies To: how can i simplify this code

### #2 jeronimo0d0a

• D.I.C Head

Reputation: 1
• Posts: 146
• Joined: 03-March 08

## Re: how can i simplify this code

Posted 07 April 2008 - 05:00 PM

This would look cleaner as a "select case" or nested for loops with intMatch(5)
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }