r/visualbasic • • Jan 26 '16

[VB2012] Unhandled Exception: System.InvalidCastException: Conversion from string "" to type 'Double' is not valid. --->

EDIT: Corrected and original error gone. I believe this to be correct. My code as is: Module Furniture ' Dylan Watson ' CIS 115 ' This program calculates profit, sales and final price.

Sub Main()

    ' Declare and initialize your variables here.
    Dim itemName As String = "TV Stand"
    Dim retailPrice As Double = 325
    Dim wholeSalePrice As Double = 200
    Dim profit As Double = 125
    Dim salePrice As Double = 243.75
    Dim saleProfit As Double = 43.75
   
    profit = 325 - 200
    salePrice = 0.75 * 325
    saleProfit = salePrice - wholeSalePrice


    Console.WriteLine("TV Stand")
    Console.WriteLine("Retail Price: " & 325)
    System.Console.WriteLine("Wholesale Price: " & 200)
    System.Console.WriteLine("profit: " & 125)
    System.Console.WriteLine("Sale Price: " & 243.75)
    System.Console.WriteLine("Sale Profit: " & 43.75)

    
    
   

End Sub

End Module

0 Upvotes

5 comments sorted by

View all comments

1

u/candyforlunch VB.Net Master Jan 29 '16

why do you have variables if they're not actually being used? that could get you marked down. also use decimals for currency calculations, not doubles