什么都不是字符串的字符 [英] Nothing as a char of a string

查看:77
本文介绍了什么都不是字符串的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从db的表中提取一些字段名称(它是一个

OledbSchemaguid表)。


对于某些OleDbSchema会出现这种情况驱动程序


NameDBField = cstr(DataRow.Item(3))


返回由字段名称字符组成的字符串,

例如MYFIELD加1无。我知道什么都没有

,因为我对这些奇怪的字符串有很多问题

我用char扫描了它们。


对于使用某个OleDbSchema驱动程序从任何oledbschemaguid

表中提取的任何字符串都会发生这种情况:总是有一个字符(

最后一个字符串)等于没什么。


很明显,我想避免做扫描的必要性去除

奇怪的Nothing char。即使trimEnd指令也不起作用,

并且这些字符串会导致程序的一般故障(对于

实例,会阻止任何字符串连接)。


我无法解释这个奇怪的事情。有没有人知道

怎么没有字符串出现在字符串中什么是最好的方法来获取它?b / b


-t

I am extracting some field names from a table of a db (it''s an
OledbSchemaguid table).

It occurs for some OleDbSchema driver that

NameDBField = cstr(DataRow.Item(3))

return a string that is composed by the characters of the field name,
for instance MYFIELD plus 1 Nothing. I know that the Nothing is there
because, since I was having a lot of problem with these strange strings
I have scanned them char by char.

This happens for any string extracted from any of the oledbschemaguid
tables using a certain OleDbSchema driver: there is always a char (the
last one ) equal to NOTHING.

Clearly, I would like to avoid the necessity to do the scan to remove
the strange Nothing char. Even the trimEnd instruction does not work,
and these strings cause general malfunnction of the program (for
instance prevent any string concatenation).

I cannot explain this strange thing. Does anybody have any idea how the
Nothing char can appear in the string and what is the best way to get
rid of it?

-t

推荐答案

到************** @ uniroma1.it 写道:
to**************@uniroma1.it wrote:
我正在提取一些数据库表中的字段名称(它是一个
OledbSchemaguid表)。

对于某些OleDbSchema驱动程序,它发生了NameDBField = cstr(DataRow) .Item(3))

返回一个字符串,由字段名称的字符组成,例如MYFIELD加1无。我知道什么都没有
因为我对这些奇怪的字符串有很多问题
我用char扫描了它们。

任何字符串都会发生这种情况使用某个OleDbSchema驱动程序从任何oledbschemaguid表中提取:总有一个char(最后一个)等于NOTHING。

很明显,我想避免有必要进行扫描以删除奇怪的Nothing char。即使trimEnd指令也不起作用,这些字符串会导致程序的一般故障(对于
实例阻止任何字符串连接)。

我无法解释这个奇怪的事情。有没有人知道
Nothing char怎么会出现在字符串中?什么是最好的方法来摆脱它?

-t
I am extracting some field names from a table of a db (it''s an
OledbSchemaguid table).

It occurs for some OleDbSchema driver that

NameDBField = cstr(DataRow.Item(3))

return a string that is composed by the characters of the field name,
for instance MYFIELD plus 1 Nothing. I know that the Nothing is there
because, since I was having a lot of problem with these strange strings
I have scanned them char by char.

This happens for any string extracted from any of the oledbschemaguid
tables using a certain OleDbSchema driver: there is always a char (the
last one ) equal to NOTHING.

Clearly, I would like to avoid the necessity to do the scan to remove
the strange Nothing char. Even the trimEnd instruction does not work,
and these strings cause general malfunnction of the program (for
instance prevent any string concatenation).

I cannot explain this strange thing. Does anybody have any idea how the
Nothing char can appear in the string and what is the best way to get
rid of it?

-t



没有任何字符是来自C ++和类似语言的\0,

终止一个带有NULL字符的字符串。 VB并不是真的知道这个角色,并且无法将它连接起来。

尝试使用此函数来处理从OleDbSchema返回的任何内容:


私有函数StripTerminator(ByVal strString As String)As String

''从Windows返回的字符串以chr(0)结尾。它需要为VB删除
。''


Dim intZeroPos作为整数


intZeroPos = InStr( strString,Chr


That nothing character is the \0 from C++ and similar languages that
terminate a string with the NULL character. VB doesn''t really
understand this character, and can''t concatenate anything to it.
Try using this function for anything you get back from the OleDbSchema:

Private Function StripTerminator(ByVal strString As String) As String
''Strings returned from Windows end in chr(0). It needs to be
removed for VB.''

Dim intZeroPos As Integer

intZeroPos = InStr(strString, Chr


(0))

如果intZeroPos> 0然后

StripTerminator =左
(0))
If intZeroPos > 0 Then
StripTerminator = Left


(strString,intZeroPos - 1)

否则

StripTerminator = strString

结束如果

结束功能

Tom
(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function
Tom


这篇关于什么都不是字符串的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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