为什么我没有使用此 VB.NET 代码声明“Trim"? [英] Why am I getting 'Trim' is not declared with this VB.NET code?

查看:25
本文介绍了为什么我没有使用此 VB.NET 代码声明“Trim"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译一个 VB.NET 应用程序.除了

...以及'IsNothing' 未声明.由于其保护级别,它可能无法访问."在这一行:

If IsNothing(memberList) = False Then

我不懂 VB,所以可能有一个简单的解决方案,但我不知道问题出在哪里.

解决方案

Trim 函数需要从程序集 Visual Basic 运行时库(在 Microsoft.VisualBasic.VisualBasic.dll)

通常最好使用字符串类中的原生 Trim 方法,而不是添加对此程序集的引用(主要用于帮助移植旧的 VB6 应用程序)

mail.CC.Add(addr.Trim())

另请注意,string.Trim 会删除其他空白字符作为制表符,而 Microsoft.VisualBasic 函数则不会.

I am trying to get a VB.NET app to compile. Besides the "elephant in the room", I'm also getting 7 "'Trim' is not declared" errors on code like this:

...as well as one "'IsNothing' is not declared. It may be inaccessible due to its protection level." on this line:

If IsNothing(memberList) = False Then

I don't know VB, so there may be a simple solution to this, but I have no clue what the problems are.

解决方案

The Trim function requires a reference to Microsoft.VisualBasic from the assembly Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Usually is preferable to use the native Trim method from the string class and not add a reference to this assembly (mainly used to help porting old VB6 apps)

mail.CC.Add(addr.Trim())

Notice also that the string.Trim removes other whitespace characters as tabs while the Microsoft.VisualBasic function does not.

这篇关于为什么我没有使用此 VB.NET 代码声明“Trim"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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