|
-
Jun 8th, 2004, 08:11 AM
#1
Thread Starter
Addicted Member
Option Strict Errors FIGURED OUT
My program works fine with option strict off but my instructor says it has to be on. Can someone tell me why I'm getting errors and how to fix them?? My errors all say Option Strict On disallows implicit conversions from 'Double' to 'String'. I highlighted where I'm getting the errors. And when I change when I change the grpSalespersons.Text to SP, grpTotalSales.Text to TS, and grpAverageSales.Text to AV; the errors go away but my program doesn't work anymore. Please help!
' Set up constants for Base pay(BP) = $500 and commission(CM) is 6%
Const BP As Double = 500.0
Const CM As Double = 0.06
Dim SA As Double
Dim GP As Double
Dim SP As Double
Dim TS As Double
Dim AV As Double
Private Sub btnGross_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGross.Click
SA = Val(nudSales.Text)
SP = Val(grpSalespersons.Text)
TS = Val(grpTotalSales.Text)
AV = Val(grpAverageSales.Text)
' Compute value and display in Gross Pay
GP = BP + SA * CM
txtGross.Text = Format(GP, "$#####0.00")
' Compute value and display in Salespersons
grpSalespersons.Text = SP + 1
' Compute value and display in Total Sales
grpTotalSales.Text = SA + TS
' Compute value and display in Average Sales
grpAverageSales.Text = TS / SP
End Sub
Last edited by twisted; Jun 8th, 2004 at 09:03 AM.
Twisted
-
Jun 8th, 2004, 08:21 AM
#2
SP is a double..... SP + 1 is still a double. A Textbox is a string.... you have to conver the number to a string......
grpSalespersons.Text = (SP+1).ToString
TG
-
Jun 8th, 2004, 08:33 AM
#3
PowerPoster
Originally posted by techgnome
SP is a double..... SP + 1 is still a double. A Textbox is a string.... you have to conver the number to a string......
grpSalespersons.Text = (SP+1).ToString
TG
I don't think that twisted is bothering to read our posts. Have a look at all his previous posts and you will find he is using VB6, but he keeps ignoring us and posts in this Forum. (As well as posting it in the Classical VB section )
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 8th, 2004, 08:49 AM
#4
Addicted Member
Re: Option Strict Errors
Originally posted by twisted
Private Sub btnGross_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGross.Click
Been a very long time since I did ordinary VB at Uni, so I may be wrong but doesn't VB use variant and doesn't have events or handlers? Even still he shouldn't be posting in the ordinary vb forum in that case.
-
Jun 8th, 2004, 08:49 AM
#5
Well, VB6 doesn't have the Option Strict setting, at least not that I am aware of.... I thought that was added to .NET specifically to allow VB6 developers to "feel comfortable" with implicit conversion.
TG
-
Jun 8th, 2004, 08:50 AM
#6
Re: Re: Option Strict Errors
Originally posted by Carnifex
Been a very long time since I did ordinary VB at Uni, so I may be wrong but doesn't VB use variant and doesn't have events or handlers? Even still he shouldn't be posting in the ordinary vb forum in that case.
Yes, VB6 has variants, yes VB6 has event and event handlers.... but the code he's posted is clearly VB.NET....
TG
-
Jun 8th, 2004, 08:52 AM
#7
Addicted Member
My bad wording there, I meant variant instead of object .
-
Jun 8th, 2004, 09:02 AM
#8
Thread Starter
Addicted Member
Guys I am using VB.Net I just posted in VB6 before I upgraded. Thanks for the help it worked like a charm. I knew what I needed to do but am such a beginner it is killing me. If you guys get a chance check out the other post by me. Can't seem to figure it out. Thanks again!
-
Jun 8th, 2004, 09:56 AM
#9
PowerPoster
HI techgnome,
"Yes, VB6 has variants, yes VB6 has event and event handlers.... but the code he's posted is clearly VB.NET...."
It is NOW. But it wasn't before he edited it. He was treating TextBox.Text as a variant.
Anyway, he has since confirmed he is working in VB.NET, but have a look at all his recent posts and you will see what I mean (including the one on Classical VB).
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 8th, 2004, 10:07 AM
#10
PowerPoster
Originally posted by twisted
Guys I am using VB.Net I just posted in VB6 before I upgraded. Thanks for the help it worked like a charm. I knew what I needed to do but am such a beginner it is killing me. If you guys get a chance check out the other post by me. Can't seem to figure it out. Thanks again!
Right. I can now see where you are coming from. You are trying to carry on with VB6 coding in .NET. Hence the problems with previous posts. Looks like your instructor is deliberately trying to emphasise this. Best of luck
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 8th, 2004, 10:42 AM
#11
Thread Starter
Addicted Member
Alright thanks man! I appreciate any help I can get!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|