By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

why doesn't this work?

P: n/a
I have code like the following set of code...

Public Structure ParamaterInformation

Public ParameterName As String

Public PromptText As String

Public DataType As String

Public DefaultValue As String

End Structure

Dim ht As New Hashtable

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

For n As Integer = 1 To 100

Dim p As ParamaterInformation

p.DefaultValue = n.ToString

ht.Add(n, p)

Next

DirectCast(ht(4), ParamaterInformation).DefaultValue = "eregergv"

End Sub

I want to go into my hash table and alter the data in the stucture at
position for and change the defaultValue to another value... but when you do

DirectCast(ht(4), ParamaterInformation).DefaultValue = "eregergv"
it gives the error expression is a value and therefore can not be the target
of an assignment... but if i assign an object to the structure from the hash
table key 4 and then assign the value to the strcture it does not keep the
changes (im assumeing its not a reference pointer like i thought it probably
was?) how would i change the value of a structure like this in a hash table?
thanks


Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
never mind i was correct, its not a reference pointer but needs reassignment
to get it to work

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:eT**************@TK2MSFTNGP11.phx.gbl...
I have code like the following set of code...

Public Structure ParamaterInformation

Public ParameterName As String

Public PromptText As String

Public DataType As String

Public DefaultValue As String

End Structure

Dim ht As New Hashtable

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

For n As Integer = 1 To 100

Dim p As ParamaterInformation

p.DefaultValue = n.ToString

ht.Add(n, p)

Next

DirectCast(ht(4), ParamaterInformation).DefaultValue = "eregergv"

End Sub

I want to go into my hash table and alter the data in the stucture at
position for and change the defaultValue to another value... but when you
do

DirectCast(ht(4), ParamaterInformation).DefaultValue = "eregergv"
it gives the error expression is a value and therefore can not be the
target of an assignment... but if i assign an object to the structure from
the hash table key 4 and then assign the value to the strcture it does not
keep the changes (im assumeing its not a reference pointer like i thought
it probably was?) how would i change the value of a structure like this in
a hash table? thanks

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.