DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Using VB.Net 2008 to convert from ASP.NET 2005 (http://www.daniweb.com/forums/thread160720.html)

Sheryl99 Dec 4th, 2008 12:24 pm
Using VB.Net 2008 to convert from ASP.NET 2005
 
I am studying VB.NET in a VB 2005 book, but using VB 2008. What is wrong with this code? I am using ASP.NET to write a web page. For each reference to:

ResultFahrenheit.Text
ResultCelsius.Text
ResultKelvin.Text

I get errors that say:
Name 'ResultFahrenheit' is not declared.
Name 'ResultCelsius' is not declared.
Name 'ResultKelvin' is not declared.

Each of these fields is a cell in a table. I tried naming the table to 'table1', then adding:

table1.ResultFahrenheit...

This took the error away from 'ResultFahrenheit', but put it on 'table1'. So, apparently the 'ResultFahrenheit' needs some type of prefix.

I'd appreciate any suggestions.
Thanks

' ----- The conversion occurs here.
        Dim origValue As Double

        If (IsNumeric(SourceValue.Text) = True) Then
            ' ----- The user supplied a number. Convert it.
            origValue = CDbl(SourceValue.Text)
            If (SourceType.SelectedValue = "F") Then
                ' ----- From Fahrenheit.
                ResultFahrenheit.Text = CStr(origValue)
                ResultCelsius.Text = CStr((origValue - 32) / 1.8)
                ResultKelvin.Text = CStr(((origValue - 32) / 1.8) + _
                  273.15)
            ElseIf (SourceType.SelectedValue = "C") Then
                ' ----- From Celsius.
                ResultFahrenheit.Text = CStr((origValue * 1.8) + 32)
                ResultCelsius.Text = CStr(origValue)
                ResultKelvin.Text = CStr(origValue + 273.15)
            Else
                ' ----- From kelvin.
                ResultFahrenheit.Text = CStr(((origValue - 273.15) * _
                  1.8) + 32)
                ResultCelsius.Text = CStr(origValue - 273.15)
                ResultKelvin.Text = CStr(origValue)
            End If
        Else
            ' ----- Unknown source value.
            ResultFahrenheit.Text = "???"
            ResultCelsius.Text = "???"
            ResultKelvin.Text = "???"
        End If

jbennet Dec 4th, 2008 1:05 pm
Re: Using VB.Net 2008 to convert from ASP.NET 2005
 
the are labels or some other GUI component

do you have labels with these names?

and 2005 and 2008 use 99% of the same code, its not a problem there

4advanced Dec 4th, 2008 1:40 pm
Re: Using VB.Net 2008 to convert from ASP.NET 2005
 
Try to find the Table, TableRow, TableCells OR Fields with yourPage.FindControl("")
If the control will be found the value can be added to it. As jbennet says, the code didn't change thát much.... so it's strange it worked in 2005 and not in 2008.


All times are GMT -4. The time now is 12:43 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC