Separate all items from a string

Asked

Viewed 208 times

2

I’m trying to make a system of save/load, I’m stuck on the loading part of the game cards, which are numbered for example: 1,2,3.

To string contains the card numbers and other information:

Nome|1,2,3,4,5,6,7,8,9|59000|50%

nome   cartas          money   reputação

My code of load:

Dim Nome As String = values(0)
Dim Cartas As String = values(1)
Dim Dinheiro As String = values(2)
Dim Reputacao As String = values(3)
MsgBox(Nome)
MsgBox(Cartas)
MsgBox(Dinheiro)
MsgBox(Reputacao)
Dim cards() As String = Cartas.Split(","c)
'MsgBox(cards)
Dim word As String
Dim b As Integer
For Each word In cards
    b = b +1
    MsgBox(word)
Next
Dim nCartas = b

I have the number of cards, how do I pick up X quantity of items from string Cards?, for example: the nCartas is 10, I want to catch the 10 strings of Cards.

1 answer

2


Dim bar() As String
Dim foo() As String
Dim i As Byte

bar = Split("Nome|1,2,3,4,5,6,7,8,9|59000|50%", "|")

foo = Split(bar(1), ",")

For i = LBound(foo) To UBound(foo)
    Debug.Print foo(i)
Next i
  • Hi, thanks for answering! o Visual Studio ta me returning this error: https://image.ibb.co/bM1s5b/232323.png Thanks in advance!

  • I managed to solve, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.