What's new

Arrays in VB? help

  • Thread starter Revvv
  • Start date
  • Views 819
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
Ok, so im getting back into making program again..so im wanting to make an array however i am getting alot of errors.


I know how you would do it in php..so could someone convert this php to a vb array?

PHP:
$array = array("Hello" => false, "name" => "somename", "something" => array("hi" => "something"))

thanks in advance..BTW ive done a google search :tongue:
 
Zorg93

NayJames123

Read Art
Fabled Veteran Modder Programmer
Messages
4,273
Reaction score
3,475
Points
650
Sin$
0
hardly ever use VB but this is the basic array structure
Code:
Dim StrArray() as String = {"Random String 1", "Random String 2", "etc", "..." }
 
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
hardly ever use VB but this is the basic array structure
Code:
Dim StrArray() as String = {"Random String 1", "Random String 2", "etc", "..." }
Yeah i know that but i need to give each part of an array a value :frown:

thanks though
 
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
hardly ever use VB but this is the basic array structure
Code:
Dim StrArray() as String = {"Random String 1", "Random String 2", "etc", "..." }
Yeah he probably needs to assign a value to a key and you can't do that directly with VB.
 
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
really? :eek: how would i go about doing it then?
You would have to use a dictionary.
Code:
Dim arr As Dictionary(Of String,Object)=New Dictionary(Of String,Object)
arr.Add("names",{"john","susan","ralph"})
arr.Add("numbers",{1,2,3,4,5,6})
arr.Add("bools",{true,true,false})
 
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
You would have to use a dictionary.
Code:
Dim arr As Dictionary(Of String,Object)=New Dictionary(Of String,Object)
arr.Add("names",{"john","susan","ralph"})
arr.Add("numbers",{1,2,3,4,5,6})
arr.Add("bools",{true,true,false})
so would this be right:
Code:
Dim arr As Dictionary(Of String,Object)=New Dictionary(Of String,Object)
arr.Add("isReadOnly",{false})
arr.Add("sku",{"393A0001"})
arr.Add("clientVersion",{3})

for
an array that needs to be

{ "isReadOnly": false, "sku": "393A0001", "clientVersion": 3 }

?
 
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
Code:
Dim arr As Dictionary(Of String,Object)=New Dictionary(Of String,Object)
arr.Add("isReadOnly", false)
arr.Add("sku", "393A0001")
arr.Add("clientVersion", 3)
 
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
Code:
Dim arr As Dictionary(Of String,Object)=New Dictionary(Of String,Object)
arr.Add("isReadOnly", false)
arr.Add("sku", "393A0001")
arr.Add("clientVersion", 3)
perfect mate! cheers for the help :smile: so how would I go about referring to this?

eg

textbox1.text = arr

?
 
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
Actually I don't think it is done that way... You have to have a predetermined format for the key and value.
Code:
Dim arr As Dictionary(Of String, Of String)=New Dictionary(Of String,Object)
arr.Add("isReadOnly", "false")
arr.Add("sku", "393A0001")
arr.Add("clientVersion", "3")
If you want to get the 3 and the false to the correct types use:
Code:
bool.tryparse(arr["isReadOnly"])
int.tryparse(arr["clientVersion"])
 
Zorg93

NayJames123

Read Art
Fabled Veteran Modder Programmer
Messages
4,273
Reaction score
3,475
Points
650
Sin$
0
from what it looks like you could possibly do with creating a struct for the data
 
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
My bad, I just looked at the first couple of posts and they didn't seem to be what he wanted lol. I guess I should have read the whole thing lol...
It's fine you linked him to a tutorial on it so he could get a solid understanding of how it works, so it is more like my bad :wink:
 
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
My bad, I just looked at the first couple of posts and they didn't seem to be what he wanted lol. I guess I should have read the whole thing lol...
Yo fire, im trying to create an auth string? is this what I am wanting?
 
ActionScript

ActionScript

XG R4PiDzZ
Grizzled Veteran Programmer Modder
Messages
2,649
Reaction score
1,405
Points
475
Sin$
0
I was going to suggest the Dictionary class, but was beaten. I'm actually using it now for a prototype of a college exercise (C#).

Not the best method, but makes your life easier than using array indexes.
Code:
Dictionary<string, Dictionary<string, string>> Results = new Dictionary<string, Dictionary<string, string>>(3)
{
      { "Mathematics", new Dictionary<string, string>() { { "Grade", "U" }, { "Marks", "0" }, } },
      { "English",     new Dictionary<string, string>() { { "Grade", "U" }, { "Marks", "0" }, } },
      { "Science",     new Dictionary<string, string>() { { "Grade", "U" }, { "Marks", "0" }, } },
};
// Results["English"]["Grade"] = "A";
 
Last edited:
Fire30

Fire30

Seasoned Member
Messages
7,222
Reaction score
2,364
Points
635
Sin$
0
Yo fire, im trying to create an auth string? is this what I am wanting?


The authstring in fifa is just a json dictionary(idk if right term?), All you have to do in python is change the false to False and it will accept it as a dict. I don't know about vb though.
 
Top Bottom
Login
Register