左右功能 [英] Left and Right Functions

查看:63
本文介绍了左右功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真是个愚蠢的问题。


Dim s As String

s ="

s = Right(s ,2)


为什么这会给我编译错误? (这适用于VB6 ..我有什么需要

才能使它在VB.Net中运行)


我导入了这个:


导入system.string

解决方案

Dim s As String

s = s.SubString (1,2)


SubString()类似于VB 6中的SUB()函数。您可以使用SubString创建自己的

Right()函数():


私函数strRight(ByVal s As String,ByVal i As Integer)As String

If Not((i> = s.Length )或(s.Length< 1))然后

s = s.Substring(s.Length - i,i)

结束如果

返回

结束功能

" patang" < PA **** @ discussions.microsoft.com>在留言中写道

news:76 ********************************** @ microsof t.com ...

这真是个愚蠢的问题。

Dim s As String
s ="
s = Right( s,2)

为什么这会给我编译错误? (这适用于VB6 ..我有什么工作才能使其在VB.Net中运行)

我已经导入了这个:
import system.string



糟糕。对不起,太久了。 SubString()就像MID(),而不是SUB。 DOH!


" Michael C#" < xy*@abcdef.com>在消息中写道

news:bX ******************* @ fe12.lga ...

Dim s As String
s = s.SubString(1,2)

SubString()就像VB 6中的SUB()函数一样。你可以创建自己的
Right()函数使用SubString():

私有函数strRight(ByVal s As String,ByVal i As Integer)As String
如果不是((i> = s.Length)或(s。长度< 1))然后
s = s.Substring(s.Length - i,i)
结束如果
返回
结束功能

patang < PA **** @ discussions.microsoft.com>在消息中写道
新闻:76 ********************************** @ microsof t.com。 ..

这真是个愚蠢的问题。

Dim s As String
s ="
s = Right(s,2)

为什么这会给我编译错误? (这适用于VB6 ..我有什么工作才能使其在VB.Net中运行)

我已经导入了这个:
进口system.string




patang,


奇怪,这给了我没有编译错误,你使用的是什么版本和

2003年你安装了SP1。


Cor

This is really silly question.

Dim s As String
s = "the"
s = Right(s, 2)

Why this gives me compilation error? (This works in VB6 .. what do I have to
do to make it work in VB.Net)

I have imported this:

imports system.string

解决方案

Dim s As String
s = s.SubString(1, 2)

SubString() is like the SUB() function in VB 6. You can create your own
Right() function using SubString():

Private Function strRight(ByVal s As String, ByVal i As Integer) As String
If Not ((i >= s.Length) Or (s.Length < 1)) Then
s = s.Substring(s.Length - i, i)
End If
Return (s)
End Function
"patang" <pa****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...

This is really silly question.

Dim s As String
s = "the"
s = Right(s, 2)

Why this gives me compilation error? (This works in VB6 .. what do I have
to
do to make it work in VB.Net)

I have imported this:

imports system.string



Oops. Sorry, been too long. SubString() is like MID(), not SUB. DOH!

"Michael C#" <xy*@abcdef.com> wrote in message
news:bX*******************@fe12.lga...

Dim s As String
s = s.SubString(1, 2)

SubString() is like the SUB() function in VB 6. You can create your own
Right() function using SubString():

Private Function strRight(ByVal s As String, ByVal i As Integer) As String
If Not ((i >= s.Length) Or (s.Length < 1)) Then
s = s.Substring(s.Length - i, i)
End If
Return (s)
End Function
"patang" <pa****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...

This is really silly question.

Dim s As String
s = "the"
s = Right(s, 2)

Why this gives me compilation error? (This works in VB6 .. what do I have
to
do to make it work in VB.Net)

I have imported this:

imports system.string




patang,

Strange, this give for me no compiling error, what version are you using and
when it is 2003 did you install the SP1.

Cor


这篇关于左右功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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