string - Simple substring program won't work -


My job tbUnos is a text input and label1 string Let's print the first two letters of the letter I have started learning Visual C ++ and I am trying to understand things.

private: System :: Void textbox 1 tags (System :: Object sender, System :: EventArgs ^ e) {

  String ^ sUnos = tbUnos - & gt; Text; Label 1- & gt; Text = sUnos-> String :: Substring (1,2);   

}

created and run, my program crashed Please help

< Div class = "post-text" itemprop = "text">

First of all it is not C ++, it is C ++ / CLI, which is targeting language extension CLI.

Second, I do not know how this is done when you do this code sUnos-> string :: substrings . However, your code should look like this:

  string ^ sUnos = tbUnos-> Text; If (! String :: IsNullOrEmpty (sUnos)) label 1- & gt; Text = sUnos-> Substrings (1,2);   

Edit: Notice this code TextChanged is the handler for the event means that you press a key every time the keyboard, such as changing text When you type the first letter in the text box, then tbUnos-> Text will be a letter and substring (1, 2) throws because there is no index to start with 1:

< example code> Argumentotofrenj Aksposn

startIndex plus length is not in this position.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -