Jump to content

I need help with an array that makes labels


Recommended Posts

Here is the code I need help with.

Dim $string = FileReadLine("wordlist.txt",3)
    Dim $stringsplit = StringSplit($string,"")
    Dim $c
    Dim $labels[20]
    For $row = 0 to $stringsplit[0] - 1
        For $c = 1 To $stringsplit[0]
            Dim $row
            Dim $a = 10 + $row*10
            Dim $b = 290
            $labels[$row] = GUICtrlCreateLabel($stringsplit[$c], $a, $b,  10, 20)
        Next
    Next

The string in the file is "abc". It makes 3 labels like I want it to but all of the labels display "c" the last character. I want the 1st label to display first character in the string and the 2nd label to display the 2nd character and the 3rd label to display the 3rd charactor and so on. If anyone can help me I will be very thankful.

.

Link to comment
Share on other sites

#include <guiconstants.au3>

GUICreate("")

    $str = "abcdefg"
    $array = StringSplit($str,"")
    For $c = 1 to $array[0]
        GUICtrlCreateLabel($array[$c], $c * 20, 10, 20)
    Next
GUISetState()

Do
    $msg = GUIGetMsg()
    sleep(10)
until $msg = $GUI_EVENT_CLOSE

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

#include <guiconstants.au3>

GUICreate("")

    $str = "abcdefg"
    $array = StringSplit($str,"")
    For $c = 1 to $array[0]
        GUICtrlCreateLabel($array[$c], $c * 20, 10, 20)
    Next
GUISetState()

Do
    $msg = GUIGetMsg()
    sleep(10)
until $msg = $GUI_EVENT_CLOSE

<{POST_SNAPBACK}>

Thank you very much for helping me. Your code helped alot.

Here is what I came up with from it

$string = FileReadLine("wordlist.txt",3)
    $stringsplit = StringSplit($string,"")
    Dim $labels[20]
        For $c = 1 To $stringsplit[0]
        $labels[$c] = GUICtrlCreateLabel($stringsplit[$c], $c * 10, 290,  10, 20)

Thank you again.

.

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...