Jump to content

VB snippet conversion help


Champak
 Share

Recommended Posts

Need some help translating this. This is an object enumeration, but how does the "Each" translate into autoit?

For Each suppSpeedX In Speeds
            
            Call lstSpeeds.AddItem(Str(suppSpeedX.SpeedR) _
                                        + "x" _
                                        + " (" _
                                        + Str(suppSpeedX.Speed) _
                                        + " kbs)" _
                                        )
            
            If (objInfo.WSpeedX = suppSpeedX.Speed) Then
                lstSpeeds.ListIndex = lstSpeeds.ListCount - 1
            End If
        Next

Thanks.

Link to comment
Share on other sites

What you have is what I've tried. So the "Each" and "Str" serve no purpose in the translation? Because I seem to only be getting the last thing/element, or whatever it's called, from the object array. I figured the "Each" would be the defining thing. What this is doing..the VB version..is adding things to a combobox. But it seems like AutoIts enumeration works differently from VBs enumeration. VBs Enumeration seems to work like AutoIts "For $x = 1" style loop. Or am I totally off base here?

Link to comment
Share on other sites

What you have is what I've tried. So the "Each" and "Str" serve no purpose in the translation? Because I seem to only be getting the last thing/element, or whatever it's called, from the object array. I figured the "Each" would be the defining thing. What this is doing..the VB version..is adding things to a combobox. But it seems like AutoIts enumeration works differently from VBs enumeration. VBs Enumeration seems to work like AutoIts "For $x = 1" style loop. Or am I totally off base here?

Do you have an object reference in $1stSpeeds that has an .AddItem method while in AutoIt? Zedna didn't show any conversion to AutoIt variable syntax. Maybe something like:
#include <GuiComboBox.au3>

Global $1stSpeed; Contains handle to combo control...
Global $1stSpeedCount; Contains count of items in combo
; ...

For $suppSpeedX In $Speeds
    _GUICtrlComboBox_AddString($1stSpeed, String($suppSpeedX.SpeedR * $suppSpeedX.Speed) & "kbs")
Next
$1stSpeedCount = _GUICtrlComboBox_GetCount($1stSpeed)

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Good thought, but I have actually been using consolewrite. I went ahead and tried _GUICtrlComboBox_AddString() anyway, but I get the same result.

EDIT: It is always the simple things. I went ahead and put a slight sleep in the loop, which I really shouldn't have to do, and that worked.

Thanks to both for the effort.

Edited by Champak
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...