如何编写一个前50个字符并丢弃其余字符的文本框语句?

编程入门 行业动态 更新时间:2024-10-24 08:20:20
本文介绍了如何编写一个前50个字符并丢弃其余字符的文本框语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何编写一个前50个字符并丢弃其余字符的文本框语句?

How do I write a textbox statement that takes the first 50 characters and discards the rest?

User = TextBox1.Text.Substring(0, 50)

错误代码:

Error Code:

Index and length must refer to a location within the string. Parameter name: length

推荐答案

在查找子字符串之前,请检查原始字符串( TextBox1.Text )长度已经小于或等于所需的长度。 你可以通过思考一下,阅读原始帮助页面或最简单的实验来弄清楚这一点。如果你要在每个简单的问题上提出这样的问题,你就永远不会成为初学者。你需要开始。
-SA
Before finding a substring, check up if the original string (TextBox1.Text) length is already less or equal to the required length. You could figure out this by thinking just a bit, reading original help page or simplest experiment. If you are going to ask such question on each simple problem, you will never become even the beginner. You need to begin.
—SA

更多推荐

如何编写一个前50个字符并丢弃其余字符的文本框语句?

本文发布于:2023-11-10 21:56:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576570.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   语句   文本框

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!