仅更新场中的第一个角色 [英] update only the first character in a feild

查看:122
本文介绍了仅更新场中的第一个角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我是VB.NET的新手,我开始创建一个有助于管理小商店的应用。

我遇到了一个问题我想只更新所有行中第一个字符=H的第一个字符并保留其余部分。



谢谢。

解决方案

假设它是一个字符串,你可以使用函数,如下所示:

 私有 共享 功能 ChangeFirst(s 作为 字符串,c 作为 字符作为 字符串 
ChangeFirst = c + s.Substring( 1
结束 功能


$ b例如,$ b以这种方式调用:

  Dim  s 作为 字符串 =   XXX  
s = ChangeFirst(s, A c)


Hello,
I'm new with the VB.NET, I started to create an app that helps to manage a small store.
I had a problem that i wanna update only the first character in all Rows where the first character = "H" and keep the rest.

Thanks.

解决方案

Assuming it is a String, you may use a Function like the following:

Private Shared Function ChangeFirst(s As String, c As Char) As String
  ChangeFirst = c + s.Substring(1)
End Function


Called, for instance, this way:

Dim s As String = "XXX"
s = ChangeFirst(s, "A"c)


这篇关于仅更新场中的第一个角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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