Results 1 to 4 of 4

Thread: Why does Visual Studio replace my message with something else?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2023
    Posts
    31

    Why does Visual Studio replace my message with something else?

    Hi everyone

    There is one thing I don't understand and I'm going crazy

    When I try to display a long message with emoji and line breaks, Visual Studio deletes my message and replaces it with resources.GetString("MyMessage.Text")

    For example I wrote this:

    Code:
    this.txtMessageLongOrder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
                | System.Windows.Forms.AnchorStyles.Left)));
                this.txtMessageLongOrder.BackColor = System.Drawing.Color.Black;
                this.txtMessageLongOrder.BorderStyle = System.Windows.Forms.BorderStyle.None;
                this.txtMessageOrder.ForeColor = System.Drawing.SystemColors.Menu;
                this.txtMessageOrder.Location = new System.Drawing.Point(6, 19);
                this.txtMessageOrder.Name = "txtMessageOrder";
                this.txtMessageOrder.Size = new System.Drawing.Size(279, 504);
                this.txtMessageOrder.TabIndex = 2;
                this.txtMessageOrder.Text = "📈 Last name\n📈 First name\n📈 Age\n📈 Address\n📈 City\n📈 Zip code\n📈 Occupation\n📈 Hobbies\n📈 Eye color\n📈 Hair color \n📈 etc...\n📈 etc...";

    Then Visual Studio turns it into:
    Code:
                this.txtMessageOrder.Text = resources.GetString("txtMessageOrder.Text");
    I need to keep the message in plain text in the code so I can make changes...

    Do you know what the problem is?

    Thanks

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Why does Visual Studio replace my message with something else?

    That looks likes C# code, not VB.Net. A VB.Net translation would look something like this:-
    Code:
    Dim sb As New System.Text.StringBuilder()
    sb.AppendLine("📈 Last name")
    sb.AppendLine("📈 First name")
    sb.AppendLine("📈 Age")
    sb.AppendLine("📈 Address")
    sb.AppendLine("📈 City")
    sb.AppendLine("📈 Zip code")
    sb.AppendLine("📈 Occupation")
    sb.AppendLine("📈 Hobbies")
    sb.AppendLine("📈 Eye color")
    sb.AppendLine("📈 Hair color")
    sb.AppendLine("📈 etc...")
    sb.AppendLine("📈 etc...")
    
    Me.txtMessageLongOrder.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                Or System.Windows.Forms.AnchorStyles.Left)), System.Windows.Forms.AnchorStyles)
    Me.txtMessageLongOrder.BackColor = System.Drawing.Color.Black
    Me.txtMessageLongOrder.BorderStyle = System.Windows.Forms.BorderStyle.None
    Me.txtMessageOrder.ForeColor = System.Drawing.SystemColors.Menu
    Me.txtMessageOrder.Location = New System.Drawing.Point(6, 19)
    Me.txtMessageOrder.Name = "txtMessageOrder"
    Me.txtMessageOrder.Size = New System.Drawing.Size(279, 504)
    Me.txtMessageOrder.TabIndex = 2
    Me.txtMessageOrder.Text = sb.ToString()
    
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Why does Visual Studio replace my message with something else?

    Yeah, it's C#, so I moved it.
    My usual boring signature: Nothing

  4. #4
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Why does Visual Studio replace my message with something else?

    Quote Originally Posted by Sun2k View Post
    Hi everyone

    There is one thing I don't understand and I'm going crazy

    When I try to display a long message with emoji and line breaks, Visual Studio deletes my message and replaces it with resources.GetString("MyMessage.Text")

    For example I wrote this:

    Code:
    this.txtMessageLongOrder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
                | System.Windows.Forms.AnchorStyles.Left)));
                this.txtMessageLongOrder.BackColor = System.Drawing.Color.Black;
                this.txtMessageLongOrder.BorderStyle = System.Windows.Forms.BorderStyle.None;
                this.txtMessageOrder.ForeColor = System.Drawing.SystemColors.Menu;
                this.txtMessageOrder.Location = new System.Drawing.Point(6, 19);
                this.txtMessageOrder.Name = "txtMessageOrder";
                this.txtMessageOrder.Size = new System.Drawing.Size(279, 504);
                this.txtMessageOrder.TabIndex = 2;
                this.txtMessageOrder.Text = "📈 Last name\n📈 First name\n📈 Age\n📈 Address\n📈 City\n📈 Zip code\n📈 Occupation\n📈 Hobbies\n📈 Eye color\n📈 Hair color \n📈 etc...\n📈 etc...";

    Then Visual Studio turns it into:
    Code:
                this.txtMessageOrder.Text = resources.GetString("txtMessageOrder.Text");
    I need to keep the message in plain text in the code so I can make changes...

    Do you know what the problem is?

    Thanks
    Firstly are you editing the auto generated designer file directly? If so then making changes via the designer can cause VS to overwrite your edits. Have you tried setting the text in the Form_Load event instead? That way it will be separate from the IDE generated code.

    Does the form have the Localizable property set to true? That might be causing VS to change your code to use the resource file and replace your manual edits.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width