如何在VB.NET中的两个其他字符串之间插入一个字符串? [英] How do I insert a string in between two other strings in VB.NET?

查看:62
本文介绍了如何在VB.NET中的两个其他字符串之间插入一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直无法在我的程序中使用这个特殊的东西。



由于我无法嵌入图像,我只会有尽可能详细地解释它。



所以,基本上,当我按下一个按钮时,组合框中的文本插入到两组文本中文本框。例如。如果组合框文本显示我是并且文本框显示Hello,autotroph。,那么当您按下按钮时,文本框会显示你好,我是自养生物。



有谁知道怎么做?



我尝试过:



我还没有尝试任何东西,我有预感它可能与Regex和诸如此类的东西有关,但我想不出任何东西:我

Hi, and I've been having trouble getting this particular thing in my program to work.

Since I can't imbed images, I will just have to explain it in as much detail as possible.

So, basically, when I press a button, the text from a combobox gets inserted between two groups of text in a textbox. E.G. If the combobox text reads "I'm" and the textbox reads "Hello, autotroph.", then when you press the button the textbox then reads "Hello, I'm autotroph."

Would anyone know how to do this?

What I have tried:

I haven't tried anything yet, I have a hunch that it might have something to do with Regex and whatnot, but I can't think of anything :I

推荐答案

这不是一个问题,我们可以说做这个并将其全部排除。

为什么不呢?好吧,想一想。为什么我是介于Hello和autotroph之间?如果方框以Hello开头怎么办?或者Hello autotroph,或Hello,我是autotrophe? 快速的棕色狐狸跳过懒狗怎么样?



机械上它很简单:一个正则表达式,string.Replace,Substring,甚至只是字符串。拆分和string.Join会这样做 - 问题是定义它应该工作的规则。而你还没有这样做。所以首先要考虑它为什么要完成以及它在哪里完成,这应该开始引导你进入一个算法,它应该给你一个实现计划。
It's not a question where we can say "do this" and it sorts it all out.
Why not? Well, think about it. Why does "I'm" go between "Hello, " and "autotroph."? What if the box starts with "Hello"? Or "Hello autotroph", or "Hello, I'm autotrophe"? How about "The quick brown fox jumps over the lazy dog"?

Mechanically it's simple to do: a Regex, string.Replace, Substring, or even just string.Split and string.Join will do it - the problem is defining the rules by which it should work. And you haven't done that. So start by thinking about why it gets done and where it gets done, and that should start to lead you to an algorithm, which should give you a plan for implementation.


这篇关于如何在VB.NET中的两个其他字符串之间插入一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆