将标签转换为空格? [英] converting tabs into spaces?

查看:72
本文介绍了将标签转换为空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i有一个vb6项目,其中一个功能是读取文本文件和

将它放入一个数组

问题是,当人们在原始文件中使用TAB键时,我只需要获取字符串中的选项卡代码,

我需要的是TAB实际上变成了很多空间...

问题是这个

可以根据TAB键的确切位置而变化!

i已经尝试了


sOrigString =替换(sOrigString,vbTab,"")


但这只是放入一个空间

当然,如果有人在线路开始处按Tab键,它会跳过光标,而不是有人在其中点击几个字符(如果你知道
$) b $ b我的意思!)


有人可以帮忙吗?


谢谢

pete

解决方案

2003年7月22日星期二15:15:07 GMT,p s < pe *********** @ hotmail.com>

写道:

大家好
我有一个vb6项目,其中一个功能是读取一个文本文件并将其放入一个数组
问题是,当人们在原始文件中使用TAB键读取时,我是
只需获取字符串中的选项卡代码,
我需要的是TAB真正成为那么多空间......
问题是这个
可能会有所不同,具体取决于TAB键的确切位置被击中了!
我试过了

sOrigString =替换(sOrigString,vbTab,"")

但这只是放在一个空间里
当然,如果有人在线的开头按Tab键,它会跳到光标的位置,而不是有人在它上面打了几个字符(如果你知道我的意思!)

有人可以帮忙吗?

感谢
pete




我不确定你是否可以获得标签以编程方式编写大小而没有一些相当复杂的复杂编码。如果您知道标签尺寸,您可以使用

之类的东西,例如

sOrigString = Replace(sOrigString,vbTab,string(nTabSize,""))


其中tabsize设置为4或8或任何你标记的内容。

史蒂夫




" steve hotmail.com>" < stesrc @< remove.this.antispam.bit>在消息中写道

news:vh ******************************** @ 4ax.com ...

2003年7月22日星期二15:15:07 GMT,p s < pe *********** @ hotmail.com>
写道:

大家好
我有一个vb6项目,一个的功能是读取文本文件并将其放入一个数组
问题是,当人们使用原始文件中的TAB键即
读取时,我只需获取选项卡代码在字符串中,我需要的是TAB真正成为那么多空间......
问题是这个
可以根据TAB键的确切位置而变化!
我试过了

sOrigString =替换(sOrigString,vbTab,"")

但这只是放在一个空间当然如果有人点击在行开头的tab键,它将
跳过光标,比如有人点击它中的几个字符(如果你知道我的意思是什么意思!)

任何人都可以帮忙?

谢谢
pete



我不确定你是否可以以编程方式获得标签大小而没有一些相当复杂的复杂编码。如果您知道选项卡大小,您可以使用类似
sOrigString = Replace(sOrigString,vbTab,string(nTabSize,""))的内容

其中设置了tabsize到4或8或你所选择的任何东西。

史蒂夫



感谢史蒂夫...

但不是实际的金额空格根据你所在的位置而变化

这条线?

例如每8个字符设置制表位...

行开头的标签将表示nTabSize = 8,5个字符和nTabSize = 3



欢呼

pete


在星期二,2003年7月22日15:43:44 GMT,p s < pe *********** @ hotmail.com>

写道:


steve hotmail。 COM>" < stesrc @< remove.this.antispam.bit>在消息中写道
新闻:vh ******************************** @ 4ax.com ..。< blockquote class =post_quotes> 2003年7月22日星期二15:15:07 GMT,p s < pe *********** @ hotmail.com>
写道:

>大家好
>我有一个vb6项目,其中一个功能是读取一个文本文件并将其放入一个数组
>问题是,当人们在原始文件中使用TAB键时,i> ;只需获取字符串中的标签代码,
>我需要的是TAB真正成为那么多空间......
>问题是这个
>可以变化取决于TAB键的确切位置!
>我试过了
>
> sOrigString = Replace(sOrigString,vbTab,"")
>
>但是这只是放入一个空间
>当然,如果有人在行的开头点击Tab键,它将跳过>光标,如果有人在其中点击了几个字符(如果你知道>我的意思!)
>
>任何人都可以帮忙吗?
>
>谢谢
> pete
> ;



我不确定你能不能得到如果没有一些相当复杂的复杂编码,则以编程方式显示选项卡大小。如果您知道选项卡大小,您可以使用类似
sOrigString = Replace(sOrigString,vbTab,string(nTabSize,""))的内容

其中设置了tabsize到4或8或你所选择的任何东西。

史蒂夫



感谢史蒂夫......
但实际的空间数量并没有变化你在哪里?
例如每8个字符设置制表位...
行开头的标签将表示nTabSize = 8,5个字符和nTabSize = 3

欢呼
pete



是的,它确实改变了复杂编码的位置。


也许你可以阅读chr的标签行。然后用

空格填充到下一个标签位置(给定一个固定的标签大小)然后

重复这个过程直到你完成。

我做了一个类似的事情,建立字符串但不是字符串

读取然后转换。如果你觉得它可能有帮助我会挖出代码

史蒂夫


hi all
i have a vb6 project, one of the functions is to read in a text file and
place it into an array
problem is, when people use the TAB key in the original file that is read, i
just get the tab code in the string,
what i need is for the TAB to literally become that many SPACES ... the
problem is this
can vary depending on where exactly the TAB key is hit!
i have tried

sOrigString = Replace(sOrigString, vbTab, " ")

but this just puts in one space
of course if someone hits the tab key at the start of the line it will jump
the cursor further than if someone hit it a few characters in (if you know
what i mean!)

can anybody help?

thanks
pete

解决方案

On Tue, 22 Jul 2003 15:15:07 GMT, "p s" <pe***********@hotmail.com>
wrote:

hi all
i have a vb6 project, one of the functions is to read in a text file and
place it into an array
problem is, when people use the TAB key in the original file that is read, i
just get the tab code in the string,
what i need is for the TAB to literally become that many SPACES ... the
problem is this
can vary depending on where exactly the TAB key is hit!
i have tried

sOrigString = Replace(sOrigString, vbTab, " ")

but this just puts in one space
of course if someone hits the tab key at the start of the line it will jump
the cursor further than if someone hit it a few characters in (if you know
what i mean!)

can anybody help?

thanks
pete



I''m not sure if you can get the tab size programatically without some
fairly complex complex coding. If you know the tab size you could just
use something like
sOrigString = Replace(sOrigString, vbTab, string(nTabSize, " "))

where tabsize is set to 4 or 8 or whatever you tabsize is.
steve



"steve hotmail.com>" <stesrc@<remove.this.antispam.bit> wrote in message
news:vh********************************@4ax.com...

On Tue, 22 Jul 2003 15:15:07 GMT, "p s" <pe***********@hotmail.com>
wrote:

hi all
i have a vb6 project, one of the functions is to read in a text file and
place it into an array
problem is, when people use the TAB key in the original file that is read, ijust get the tab code in the string,
what i need is for the TAB to literally become that many SPACES ... the
problem is this
can vary depending on where exactly the TAB key is hit!
i have tried

sOrigString = Replace(sOrigString, vbTab, " ")

but this just puts in one space
of course if someone hits the tab key at the start of the line it will jumpthe cursor further than if someone hit it a few characters in (if you knowwhat i mean!)

can anybody help?

thanks
pete



I''m not sure if you can get the tab size programatically without some
fairly complex complex coding. If you know the tab size you could just
use something like
sOrigString = Replace(sOrigString, vbTab, string(nTabSize, " "))

where tabsize is set to 4 or 8 or whatever you tabsize is.
steve


thanks steve...
but doesnt the actual amount of spaces change depending on where you are in
the line?
e.g. tab stops are set up every 8th character... tabbing at start of the
line will mean nTabSize =8 , 5 chars in and nTabSize=3
?
cheers
pete


On Tue, 22 Jul 2003 15:43:44 GMT, "p s" <pe***********@hotmail.com>
wrote:


"steve hotmail.com>" <stesrc@<remove.this.antispam.bit> wrote in message
news:vh********************************@4ax.com.. .

On Tue, 22 Jul 2003 15:15:07 GMT, "p s" <pe***********@hotmail.com>
wrote:

>hi all
>i have a vb6 project, one of the functions is to read in a text file and
>place it into an array
>problem is, when people use the TAB key in the original file that isread, i >just get the tab code in the string,
>what i need is for the TAB to literally become that many SPACES ... the
>problem is this
>can vary depending on where exactly the TAB key is hit!
>i have tried
>
>sOrigString = Replace(sOrigString, vbTab, " ")
>
>but this just puts in one space
>of course if someone hits the tab key at the start of the line it willjump >the cursor further than if someone hit it a few characters in (if youknow >what i mean!)
>
>can anybody help?
>
>thanks
>pete
>



I''m not sure if you can get the tab size programatically without some
fairly complex complex coding. If you know the tab size you could just
use something like
sOrigString = Replace(sOrigString, vbTab, string(nTabSize, " "))

where tabsize is set to 4 or 8 or whatever you tabsize is.
steve


thanks steve...
but doesnt the actual amount of spaces change depending on where you are in
the line?
e.g. tab stops are set up every 8th character... tabbing at start of the
line will mean nTabSize =8 , 5 chars in and nTabSize=3
?
cheers
pete


Yes it does change which is where the complex coding comes in.

Maybe you could read the line up to a tab chr. Then pad out with
spaces up to the next tab position (given a fixed tab size) then
repeat the process until you are finished.

I''ve done a similar thing building strings but not on strings being
read then converted. I''ll dig out the code if you think it might help
steve


这篇关于将标签转换为空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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