Universe Sandbox

General Category => Everything Else => Topic started by: atomic7732 on September 20, 2012, 08:43:12 AM

Title: i need this code
Post by: atomic7732 on September 20, 2012, 08:43:12 AM
Visual Basic
Code: [Select]
       If control(0) = "A" Then
            procount(0) = procount(0) + 1
        ElseIf control(1) = "A" Then
            procount(1) = procount(1) + 1
        ElseIf control(2) = "A" Then
            procount(2) = procount(2) + 1
        ElseIf control(3) = "A" Then
            procount(3) = procount(3) + 1
        End If
not to mention that this is only checking 4 spots in an array, think of all the copying and pasting if you have 16 indices... or 64... or more!

Python
Code: [Select]
pcount = 0

control = [
    "A", "B", "C", "D", "A", "A", "B", "A"
]

for x in control:
    if x == "A":
        pcount = pcount + 1
        
print pcount    

Any amount in the array and the same 3 lines of the for loop works. BOOM

Or maybe I don't know how to do a for loop in VB

Actually that's probably it.


Anyway I need this code for reasons. I'll try to make a map game using python with TkInter and stuff yes.

(http://i.imgur.com/y58hv.png)
 ^ How far I was in VB
Title: Re: i need this code
Post by: vh on September 20, 2012, 12:13:17 PM
have you figured out how to erase or move lines/objects in tkinter?
Title: Re: i need this code
Post by: atomic7732 on September 20, 2012, 12:20:15 PM
yes I can erase a specific id, but not any/all, sadly