Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8237475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:28:50+00:00 2026-06-07T19:28:50+00:00

I keep getting this annoying message (even though it is my fault): Conversion from

  • 0

I keep getting this annoying message (even though it is my fault):

Conversion from string “” to type ‘Double’ is not valid.

I get this message when I am debugging in VB 2010 Express and I hit the “SLM” button. What the heck does this mean and what am I doing wrong?!?!

My code:

Public Class frmAssignment_5

    Private Sub btnSLM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSLM.Click
        Dim Description As String
        Dim Year As String
        Dim Life As String
        Dim SLMDepreciation As String
        Dim SLMText As String = "straight-line"

        txtDescription.Clear()
        txtYear.Clear()
        txtCost.Clear()
        txtLife.Clear()
        lstResult.ClearSelected()

        Description = CStr(txtDescription.Text)
        Year = CStr(txtYear.Text)
        Life = CStr(txtLife.Text)
        SLMDepreciation = CStr(SLMD())

        lstResult.Items.Add("Description: " & Description)
        lstResult.Items.Add("Year of purchase: " & Year)
        lstResult.Items.Add("Cost: " & FormatCurrency(CStr(txtCost.Text), 2))
        lstResult.Items.Add("Estimated life: " & Life)
        lstResult.Items.Add("Method of depreciation: " & SLMText)


    End Sub

    Function SLMD() As Double
        Dim Salvage_Value As Integer = 0
        Dim Life As String = CStr(txtLife.Text)
        Dim Cost As String = CStr(txtCost.Text)

        SLMD = (CDbl(txtCost.Text) - Salvage_Value) / CDbl(Life)

        Return SLMD
    End Function
End Class

The error keeps happening at the “SLMD = (CDbl(txtCost.Text) – Salvage_Value) / CDbl(Life)” but when I change things around, it starts pointing at the things that I change with the same error.

If anyone can help me out, I will be in forever debt…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:28:52+00:00Added an answer on June 7, 2026 at 7:28 pm

    VB is complaining because you are trying to convert an empty String “” value to a number. If you put VAL() around each string, it will convert it to zero.

    Salvage_Value is also declared as an Integer, but you are using it as a Double, so you need to convert that too when calculating SLMD:

    SLMD = (Val(txtCost.Text) - CDbl(Salvage_Value)) / Val(Life)
    

    You also have a risk of a division by zero error if “Life” is not set to a value, so you should add code to make sure a value is entered there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error: initializer-string for array of chars is too long Even
I keep getting this error - error C2819: type 'List' does not have an
I keep getting this error on emulator: I copied this from a tutorial and
I keep getting this RuntimeError which I'm not sure how to fix. Here's what
I keep getting this error: Could not load file or assembly 'Facebook, Version=5.4.1.0, Culture=neutral,
I keep getting this error after cloning a repository from the AndEngine project.. The
I keep getting this weird output from my code everytime I use the 'start
I keep getting this error message in my Event log: The root of the
I keep getting this message (in the title). Just take a quick look at
I keep getting this error from my code and I have no idea what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.