Jump to content

[HELP] Combobox and splitting problem


..:D&G:..

Recommended Posts

Hello guys, I am trying to make a currency exchange window. You select the currency from a combobox, which is like this: "Dollars - USD" and I use this to split the "Dollars" (name) from the "USD" (initial):

local listFrom = guiComboBoxGetSelected(currencyListFrom) 
            local textFrom = guiComboBoxGetItemText(currencyListFrom, listFrom) 
            local splittedNameFrom = split ( tostring ( textFrom ), " - " ) 
            local currencyNameFrom = tostring ( splittedNameFrom [ 1 ] ) 
            local currencyInitialsFrom = tonumber ( splittedNameFrom [ 2 ] ) 

The problem is that if I try to output "currencyInitialsFrom" into outputChatBox it gets nil, any ideas why?

Thanks.

Link to comment

Are you sure textFrom is returning the proper text?

I tested this in runcode:

crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 

And it works properly,

PIFBmm4.png

so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

  • Like 1
Link to comment
Are you sure textFrom is returning the proper text?

I tested this in runcode:

crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 

And it works properly,

PIFBmm4.png

so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

In the picture, you tried without spaces so try without spaces.

Link to comment
Are you sure textFrom is returning the proper text?

I tested this in runcode:

crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 

And it works properly,

PIFBmm4.png

so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

In the picture, you tried without spaces so try without spaces.

What spaces? I see that he used the spaces between the text and - ...

Link to comment

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
  • Recently Browsing   0 members

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