473,856 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Value of type 'Integer' cannot be converted

I'm learning form an ASP.NET 1.0 book and I tried out some code that returns
this error:

Compiler Error Message: BC30311: Value of type 'Integer' cannot be converted
to 'ASP.multiclass es_aspx.Vehicle Key'.

Source Error:
Line 106:
Line 107: Response.Write( "<br/>Attempting to start DodgeCar with
PlymouthKey: ")
Line 108: DodgeCar.Igniti on(789)
Line 109: Response.Write( DodgeCar.IsRunn ing)
Line 110:

Source File: E:\hhsinternal\ multiclasses.as px Line: 108

I tried this on .NET 1.1 and 2.0 Beta. I don't have any .NET 1.0 machines to
see if this worked or not. I'm hoping one of you experts can show me the
errors of my coding ways.

Here's the full code if needed:

<script runat="server">

Public Class VehicleKey

Private _Shape As Integer
Public Sub New(ByVal newShape As Integer)

_Shape = newShape

End Sub
Public ReadOnly Property Shape() As Integer

Get

Return _Shape

End Get

End Property

End Class
Public Class Car

Private _Color As String

Private _Gear As Integer

Private _Ignition As Integer

Private _EngineRunning As Boolean

Private Shared _Count = 0
Public Shared ReadOnly Property Count() As Integer

Get

Return _Count

End Get

End Property
Public Property Color() As String

Get

Return _Count

End Get

Set(ByVal value As String)

_Color = value

End Set

End Property
Public ReadOnly Property Gear() As Integer

Get

Return _Gear

End Get

End Property
Public ReadOnly Property IsRunning() As String

Get

If _EngineRunning Then

Return "The engine is running."

Else

Return "The Engine Is Not Running!"

End If

End Get

End Property
Public Overloads Sub ChangeGear(ByVa l direction As Integer)

If direction < 0 Then _Gear = Gear - 1

If direction > 0 Then _Gear = Gear + 1

If _Gear > 5 Then _Gear = 5

If _Gear < -1 Then _Gear = -1

End Sub
Public Overloads Sub ChangeGear(ByVa l direction As String)

If direction = "down" Then ChangeGear(-1)

If direction = "up" Then ChangeGear(+1)

End Sub
Public Sub Ignition(ByVal IgnitionKey As VehicleKey)

If IgnitionKey.Sha pe = _Ignition Then _EngineRunning = True

End Sub
Public Sub EngineOff()

_EngineRunning = False

End Sub
Sub New(ByVal IgnitionShape As Integer)

_Color = "Sparkle Midnight Blue"

_Ignition = IgnitionShape

_Count = Count + 1

End Sub

End Class
Sub Page_Load()

Dim HondaKey As New VehicleKey(123)

Dim DodgeKey As New VehicleKey(456)

Dim PlymouthKey As New VehicleKey(789)
Dim DodgeCar As New Car(456)

Response.Write( "<div style=""font-family: arial; font-size: 110%;"">New
Object DodgeCar Created.</div>")
Response.Write( "<br />Color: " & DodgeCar.Color)

Response.Write( "<br />Gear: " & DodgeCar.Gear)
DodgeCar.Color = "Silver"

DodgeCar.Change Gear("up")

Response.Write( "<br /><b>Propertie s Updated</b>")
Response.Write( "<br/>New Color: " & DodgeCar.Color)

Response.Write( "<br/>New Gear: " & DodgeCar.Gear)
DodgeCar.Change Gear(+1)

Response.Write( "<br/>Shfted the gear up one.")

Response.Write( "<br/>New Gear: " & DodgeCar.Gear)
Response.Write( "<br/>Attempting to start DodgeCar with PlymouthKey: ")

DodgeCar.Igniti on(789)

Response.Write( DodgeCar.IsRunn ing)
Response.Write( "<hr/>Attempting To Start DodgeCar with HondaKey: ")

DodgeCar.Igniti on(123)

Response.Write( DodgeCar.IsRunn ing)
Response.Write( "<hr/>Attempting To Start DodgeCar with DodgeKey: ")

DodgeCar.Igniti on(456)

Response.Write( DodgeCar.IsRunn ing)

Response.Write( "<br/>Attempting to stop DodgeCar: ")

DodgeCar.Engine Off()

Response.Write( DodgeCar.IsRunn ing)

End Sub

</script>

Thanks,
Jim
Nov 21 '05 #1
2 7220

"Compiler Error Message: BC30311: Value of type 'Integer' cannot be
converted to 'ASP.multiclass es_aspx.Vehicle Key'."

It is expecting a VehicleKey type of object. You can not send in an
Interger when it expects a VehicleKey type.

From what your code looks like you could do something like:
Line 108: DodgeCar.Igniti on(new VehicleKey(789) )

Or since you defined did: "Dim PlymouthKey As New VehicleKey(789) " you could
just pass in PlymouthKey
Line 108: DodgeCar.Igniti on(PlymouthKey)
Make sure you turn "Option Strict On" This will help you figure these
errors out at design time.

Hope this helps
Chris
"Jim in Arizona" <ti*******@hotm ail.com> wrote in message
news:eU******** **********@TK2M SFTNGP11.phx.gb l...
I'm learning form an ASP.NET 1.0 book and I tried out some code that
returns this error:

Compiler Error Message: BC30311: Value of type 'Integer' cannot be
converted to 'ASP.multiclass es_aspx.Vehicle Key'.

Source Error:
Line 106:
Line 107: Response.Write( "<br/>Attempting to start DodgeCar with
PlymouthKey: ")
Line 108: DodgeCar.Igniti on(789)
Line 109: Response.Write( DodgeCar.IsRunn ing)
Line 110:

Source File: E:\hhsinternal\ multiclasses.as px Line: 108

I tried this on .NET 1.1 and 2.0 Beta. I don't have any .NET 1.0 machines
to see if this worked or not. I'm hoping one of you experts can show me
the errors of my coding ways.

Here's the full code if needed:

<script runat="server">

Public Class VehicleKey

Private _Shape As Integer
Public Sub New(ByVal newShape As Integer)

_Shape = newShape

End Sub
Public ReadOnly Property Shape() As Integer

Get

Return _Shape

End Get

End Property

End Class
Public Class Car

Private _Color As String

Private _Gear As Integer

Private _Ignition As Integer

Private _EngineRunning As Boolean

Private Shared _Count = 0
Public Shared ReadOnly Property Count() As Integer

Get

Return _Count

End Get

End Property
Public Property Color() As String

Get

Return _Count

End Get

Set(ByVal value As String)

_Color = value

End Set

End Property
Public ReadOnly Property Gear() As Integer

Get

Return _Gear

End Get

End Property
Public ReadOnly Property IsRunning() As String

Get

If _EngineRunning Then

Return "The engine is running."

Else

Return "The Engine Is Not Running!"

End If

End Get

End Property
Public Overloads Sub ChangeGear(ByVa l direction As Integer)

If direction < 0 Then _Gear = Gear - 1

If direction > 0 Then _Gear = Gear + 1

If _Gear > 5 Then _Gear = 5

If _Gear < -1 Then _Gear = -1

End Sub
Public Overloads Sub ChangeGear(ByVa l direction As String)

If direction = "down" Then ChangeGear(-1)

If direction = "up" Then ChangeGear(+1)

End Sub
Public Sub Ignition(ByVal IgnitionKey As VehicleKey)

If IgnitionKey.Sha pe = _Ignition Then _EngineRunning = True

End Sub
Public Sub EngineOff()

_EngineRunning = False

End Sub
Sub New(ByVal IgnitionShape As Integer)

_Color = "Sparkle Midnight Blue"

_Ignition = IgnitionShape

_Count = Count + 1

End Sub

End Class
Sub Page_Load()

Dim HondaKey As New VehicleKey(123)

Dim DodgeKey As New VehicleKey(456)

Dim PlymouthKey As New VehicleKey(789)
Dim DodgeCar As New Car(456)

Response.Write( "<div style=""font-family: arial; font-size: 110%;"">New
Object DodgeCar Created.</div>")
Response.Write( "<br />Color: " & DodgeCar.Color)

Response.Write( "<br />Gear: " & DodgeCar.Gear)
DodgeCar.Color = "Silver"

DodgeCar.Change Gear("up")

Response.Write( "<br /><b>Propertie s Updated</b>")
Response.Write( "<br/>New Color: " & DodgeCar.Color)

Response.Write( "<br/>New Gear: " & DodgeCar.Gear)
DodgeCar.Change Gear(+1)

Response.Write( "<br/>Shfted the gear up one.")

Response.Write( "<br/>New Gear: " & DodgeCar.Gear)
Response.Write( "<br/>Attempting to start DodgeCar with PlymouthKey: ")

DodgeCar.Igniti on(789)

Response.Write( DodgeCar.IsRunn ing)
Response.Write( "<hr/>Attempting To Start DodgeCar with HondaKey: ")

DodgeCar.Igniti on(123)

Response.Write( DodgeCar.IsRunn ing)
Response.Write( "<hr/>Attempting To Start DodgeCar with DodgeKey: ")

DodgeCar.Igniti on(456)

Response.Write( DodgeCar.IsRunn ing)

Response.Write( "<br/>Attempting to stop DodgeCar: ")

DodgeCar.Engine Off()

Response.Write( DodgeCar.IsRunn ing)

End Sub

</script>

Thanks,
Jim

Nov 21 '05 #2
"Chris, Master of All Things Insignificant" <chris@No_Spam_ Please.com> wrote
in message news:eE******** *******@TK2MSFT NGP10.phx.gbl.. .

"Compiler Error Message: BC30311: Value of type 'Integer' cannot be
converted to 'ASP.multiclass es_aspx.Vehicle Key'."

It is expecting a VehicleKey type of object. You can not send in an
Interger when it expects a VehicleKey type.

From what your code looks like you could do something like:
Line 108: DodgeCar.Igniti on(new VehicleKey(789) )

Or since you defined did: "Dim PlymouthKey As New VehicleKey(789) " you
could just pass in PlymouthKey
Line 108: DodgeCar.Igniti on(PlymouthKey)
Make sure you turn "Option Strict On" This will help you figure these
errors out at design time.

Hope this helps
Chris


--------SNIP-----------
That was exactly what I needed to know. Actually, it was similar in the book
and somehow along the way I must of stopped paying attention to what I was
doing.

Thanks Chris.
Jim
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
386
by: Supra | last post by:
: error BC30311: Value of type 'System.Drawing.Color' cannot be converted to 'Integer'. Function doColor(ByVal rtb As RichTextBox, ByVal a As String, Optional ByVal f As Integer = 0, Optional ByVal bg As Integer = 0) Dim b As String, n, fgcolor, bgcolor As Integer Dim colour(15) As Color colour(0) = Color.White colour(1) = Color.Black
9
2937
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval ("document.forms."+rowString+".value")) == true ) { //this alert works if the value is a letter,i.e,"a" alert("You have entered an non-numeric value.\nEnter a number in the appropriate box.");
12
3225
by: Francois Grieu | last post by:
The values of ((int)0.7) and ((int)-0.7) seem to be 0 Is this independent of implementation ? TIA, François Grieu
16
5160
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. And K&R2 mentions "signed extension" everywhere. Reading some old clc posts, I've beginning to realize that these books are over-generalizing the topic. I am just wondering what the difference between the following pairs of terms are: 1)...
23
2200
by: Tomás | last post by:
Anything wrong with the following code?: #include <cstdlib> int main() { for (unsigned i = 0; i != 1000; ++i) { int *p = reinterpret_cast<int*>( std::rand() );
40
9804
by: Zach | last post by:
Can someone please explain what this means and illustrate the difference with some code. Thanks, Zach
3
2448
by: cmdolcet69 | last post by:
I can the following error message "value of type byte cannot be converted to 1-dimentional array of byte" when i execute this line of code: moRS232.Write(Packet(i)) it underline the packet(i) this is my declared array of byte size (6)
69
3350
by: Horacius ReX | last post by:
Hi, I have the following program structure: main ..... int A=5; int* ptr= A; (so at this point ptr stores address of A) ..... .....
14
1780
by: KK | last post by:
Dear All I have a small problem with using as operator on value type array. Here is an example what I am trying to do. using System; using System.Collections.Generic; using System.Text;
0
9758
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11049
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7928
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4169
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.