I Make Encode Text Program Then I use Function

TextBox2.Text = Passed(Microsoft.VisualBasic.Right(nowvalue, 5)) & " " & TextBox2.Text

And It tell This Error

Operator '&' is not defined for types 'System.Drawing.StringFormat' and 'String'.

Why "&" is caught in function but it seperate from "()"
First And
My Code Is Very Long
Thank For Help

Dani AI

Generated

That kind of compile error means one side of your concatenation is not a String object — it’s some other type (often a drawing helper object such as StringFormat) that the & operator cannot join to a string. Since later noted the problem was found, these are the checks and fixes that will help anyone who sees the same symptom.

  • Inspect the types involved. In Visual Studio use Quick Info (hover) and F12 to open the definition of any function or symbol and confirm its return/type. Look for a function or variable whose type is not String and that might be used in the expression.
  • Watch for name collisions: a field, control, or local with the same name as a function can shadow the function and change the type used at compile time.
  • Make the intent explicit. Convert non-string operands to text (.ToString() or CStr(...)), or change the function/property to return a String if textual output is intended. If the object truly is a StringFormat (a drawing class), use the appropriate text source instead of trying to concatenate that object. See the StringFormat class for context: System.Drawing.StringFormat.

Enable Option Strict On to force explicit conversions at compile time and catch these errors earlier: . For general concatenation guidance and best practices see the VB string docs: .

Thanks to for updating the thread, and to for the reminder to mark solved when fixed.

Recommended Answers

All 2 Replies

I Make Encode Text Program Then I use Function

TextBox2.Text = Passed(Microsoft.VisualBasic.Right(nowvalue, 5)) & " " & TextBox2.Text

And It tell This Error

Operator '&' is not defined for types 'System.Drawing.StringFormat' and 'String'.

Why "&" is caught in function but it seperate from "()"
First And
My Code Is Very Long
Thank For Help

Sorry I Found My Problem After Posting Astonishing
Thank For Seeing

Please mark this thread as solved if you have found an answer to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.