Wednesday, March 28, 2012
String. Is this Possible? Still trying to figure this out after 4 hours. Thank You.
I am changing the property of a control:
myMenu.Item(0).Item(1).Text = "Something"
What I want is to use the path which value is in a string. Something like:
Dim path As String = ".Item(0).Item(1)."
Now I would to the following:
myMenu & path & Text = "Something"
Of course this doesn't work.
Any ideas?
Thank You,
Miguel
There is no simple solution that will enable that idea to work. Youcould get it to work using a utility method that parses the path string, and then attempts to find the various properties within that string. However, that would be a needlessly slow, complex, and error-prone way to find a control.
Whatever it is that you're trying to achieve, you should perhaps reconsider it. I'm sure you'll come up with a simpler solution.
Monday, March 26, 2012
string[] and session
I have a string[] which I have added to Session.
I want to them retrieve a certain part of the string[] array, given an index, from the Session variable - but how do I do this?string sSomeVal = ((string[])Session["StringVariableName"])[iIndex];
ill give this a whirl - thanks!!! :)
And thanks for the positive feedback too! =)
no worries ;) Mr. "RAT" :P
Tuesday, March 13, 2012
Stuck again
Here is my problem
I have a sql database with a field voucherRate(int4) that contains a figure that will be used to create a discount.
Here is my code so far
'Declare the discount string
dim strDiscount as double
'declare the total string
dim strTotal as double = 10
Sub Page_Load
'set up connection to db
Dim conNorthwind As SqlConnection
Dim dsEmployees As DataSet
dsEmployees = New Dataset' Retrieve records from database
conNorthwind = New SqlConnection( "server=(local);uid=sa;pwd=*****;database=dbSQL" )
Dim daEmployees As SQLDataAdapter
daEmployees = New SqlDataAdapter( "Select voucherRate from vouchers", conNorthwind )
daEmployees.Fill( dsEmployees, "voucherRate" )conNorthwind.Close()
strDiscount = daEmployees( "VoucherRate" )
End Sub
OK what I need to add but am really struggling with is this;
strDiscount = "DataSet Voucher Rate" / 100 * strTotal
What would be the correct syntax for creating this stringFirst of all...
I find your variable names very different...
I am not sure why you have "str" before all your variables...
Check out MSDN site for naming convention...
Anyhow...
here's the code to access your voucherRate field...
conNorthwind.close()strDiscount = CType(dsEmployees.Tables(0).Rows(0).Item("voucherRate"),Integer)/100 * strTotal
But please note that your dataset might have more than one records and hence you have to loop through the dataset to calculate discount for all the records...