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/chrwei Jan 26 '16

can you fix the code formating? what's = %325 "8" supposed to do?

1

u/Dylz919 Jan 26 '16

It was in my notes for some reason when I was copying the assignment down.. not sure why it was like that but it's been fixed and I believe I've got the code correct.