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

  • Home
  • SEARCH
  • 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 6794981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:17:16+00:00 2026-05-26T18:17:16+00:00

Question: The below program throws a runtime error (invalid conversion from double) because there

  • 0

Question:

The below program throws a runtime error (invalid conversion from double) because there is

 + _

followed by a newline and a

 +"

In other words, it’s

"SomeString" + "someotherstring" ++ "yet another string"

 

<STAThread()> _
Sub Main()
    Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder

    Dim dt As New DataTable
    dt.Columns.Add("oeId", GetType(String))
    dt.Columns.Add("ZO_RM_Name", GetType(String))
    dt.Columns.Add("ZO_GB_Name", GetType(String))
    dt.Columns.Add("gubeg", GetType(DateTime))
    dt.Columns.Add("guend", GetType(DateTime))

    Dim dr As DataRow = Nothing

    For i As Integer = 0 To 10 Step 1
        dr = dt.NewRow()
        dr("oeId") = "Organization Unit id " + (i * 1000).ToString()
        dr("ZO_RM_Name") = "Room " + i.ToString()
        dr("ZO_GB_Name") = "Building " + i.ToString()
        dr("gubeg") = System.DateTime.Now
        dr("guend") = System.DateTime.Now.AddDays(22).AddYears(20).AddHours(2)
        dt.Rows.Add(dr)
    Next

    For Each drThisRow As DataRow In dt.Rows
        sb.AppendLine("Organisationseinheit " + drThisRow("oeId").ToString() + _
                               +" in Raum " + drThisRow("ZO_RM_Name").ToString() + " von Gebäude " + drThisRow("ZO_GB_Name").ToString() _
                               + " in der Gültigkeit von " + drThisRow("gubeg").ToString() + " bis " + drThisRow("guend").ToString() + "." _
        )
    Next
End Sub '' Main ''

One could simplify this problem to this one:

 Dim newstring As String = "SomeString" + "someotherstring" + +"yet another string"

It compiles fine, but when the program is run, it throws a runtime error.
Is this a compiler bug ?
Shouldn’t it stop me with a compiler error, like invalid syntax ?

  • 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-05-26T18:17:17+00:00Added an answer on May 26, 2026 at 6:17 pm

    The + operator comes in two variants:

    • a binary operator, a + b
    • a unary operator, +a

    The first one says “take a and add b and produce the results”. The second one says “take a with a positive sign”.

    In this case, the expression is evaluated as a string + a double, because VB.NET, with OPTION STRICT OFF will think that you want the second operand here as a string, that will be autoconverted to a double at runtime, because you prefixed it with the unary + operator.

    Set OPTION STRICT ON to make VB.NET be more strict with its typechecking at compiletime, at the expense of you having to write code a bit more specific in some cases.

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

Sidebar

Related Questions

This is with reference to the below question: Execute program from within a C
(See question below for more context): Are there any situations in which <machineKey validationKey=AutoGenerate,IsolateApps
Note The question below was asked in 2008 about some code from 2003. As
The original question is below, but I changed the title because I think it
I have a simple question: Why the program below does not write the whole
Here is the output for the below program. value is : 2.7755575615628914E-17 Double.compare with
With respect to my yesterday's question on invoking RPG program using Java, the below
The question below is not really a programming question, but more of how can
ORIGINAL (see UPDATED QUESTION below) I am designing a new laboratory database that tests
Thanks to AakashM, he led me in the right direction. For the question below,

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.