Updating list of objects (not their values)
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts
Page 1 of 1
Hi,
Is it possible to fill a list with for example:
...and have it actually update as the variables change? For example, if you changed a to "another string" it would update in the list as well (as it doesn't if you just add a, b and c at the start, you add their values not the variables themselves)? I know/think it can be done with classes but i don't want to have a different class for all of my variables.
I would use it so I'd add variables to a list, and then their values would be displayed during a "debug mode" (and I am aware of all the visual studio ways i can see what value they hold, i want it IN my program).
Thanks in advance!
Is it possible to fill a list with for example:
Code: Select all
(displaying the list would show "string 42 True")a = "string"
b = 42
c = True
...and have it actually update as the variables change? For example, if you changed a to "another string" it would update in the list as well (as it doesn't if you just add a, b and c at the start, you add their values not the variables themselves)? I know/think it can be done with classes but i don't want to have a different class for all of my variables.
I would use it so I'd add variables to a list, and then their values would be displayed during a "debug mode" (and I am aware of all the visual studio ways i can see what value they hold, i want it IN my program).
Thanks in advance!
You may find it useful to put the variables in a List object. This would let you add, remove, change, and access each item.
There are some samples here: http://msdn.microsoft.com/en-us/library ... S.95).aspx
There are some samples here: http://msdn.microsoft.com/en-us/library ... S.95).aspx
Thank you for your reply, though this might not be what i'm after.
As far as I'm aware, if you add A (A="string123") to a list (of string) and later change A (to, for example "str000"), there will still be initial value in the list. It would my guess that you only add A's value into the list so the two aren't in any way linked.
I could do this by having a class, put it's instance in a list and then change it's property A.
What i'm asking is, is there any way to link A and the list, so you could dumb a bunch of variables - not their values - (preferably different types) in a list.
As far as I'm aware, if you add A (A="string123") to a list (of string) and later change A (to, for example "str000"), there will still be initial value in the list. It would my guess that you only add A's value into the list so the two aren't in any way linked.
I could do this by having a class, put it's instance in a list and then change it's property A.
What i'm asking is, is there any way to link A and the list, so you could dumb a bunch of variables - not their values - (preferably different types) in a list.
Maybe you could use something like:
Code: Select all
d will say: "string 42 True" and you can change the values at anyway and just use d again.Dim a = "string"
Dim b = 42
Dim c = True
Dim d As String = a & " " & b & " " & c
MsgBox(d)
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
Let me clarify the thing by explaining it's purpose:
I'm making a little game. I also have an overlay-thing-class that displays values of certain variables in-game.
I could of course make variables public or something and add the code into overlay so it would check them and display their values.
BUT. I was wondering, if i quickly wanted to know x&y of something, i would write something like "debug_queue.add(variable)"
and the overlay thing would periodically go over this list and display the current variable values, even if they were changed at runtime/later/after adding them in.
I'm sorry for not making it clear at first, and it may just be that such a thing is not doable, but if it is, I do think it would be a nice feature. It may seem a bit contrived, but with the system i currently have it would be perfect.
I'm making a little game. I also have an overlay-thing-class that displays values of certain variables in-game.
I could of course make variables public or something and add the code into overlay so it would check them and display their values.
BUT. I was wondering, if i quickly wanted to know x&y of something, i would write something like "debug_queue.add(variable)"
and the overlay thing would periodically go over this list and display the current variable values, even if they were changed at runtime/later/after adding them in.
I'm sorry for not making it clear at first, and it may just be that such a thing is not doable, but if it is, I do think it would be a nice feature. It may seem a bit contrived, but with the system i currently have it would be perfect.
I'm trying to figure out what you want I am a little confused sorry i didn't read your thread properly
So you don't want their values you want their their type?
So you don't want their values you want their their type?
Code: Select all
That can be used to check if they are a certain type if might be easier to do it over Skype call or Teamviewer, if you want to do that feel free to message me the details. Sorry if I am not being much helpDim a As String = "string"
Dim b As Integer = 42
Dim c As Boolean = True
If VarType(a) = vbString Then
MsgBox("a IS a string")
End If
If VarType(b) = vbInteger Then
MsgBox("b IS an integer")
End If
If VarType(c) = vbBoolean Then
MsgBox("c IS a boolean")
End If
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
While writing my reply for the second time (pressed backspace outside of textbox, got screwed over)
I have concluded that what I'm after cannot be done, and neither can my examples.
We could go over it on Skype/TW if you want (note I have CET time), including my current game thing but
for now I'll mark this thread as closed, and a pointless wasting of your time ;)
I have concluded that what I'm after cannot be done, and neither can my examples.
We could go over it on Skype/TW if you want (note I have CET time), including my current game thing but
for now I'll mark this thread as closed, and a pointless wasting of your time ;)
7 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023