拆分字符串并获取值并删除Visual Basic 6.0中的值 [英] split string and get value and remove value in Visual Basic 6.0

查看:157
本文介绍了拆分字符串并获取值并删除Visual Basic 6.0中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何拆分字符串并在结果字符串中获取特定值,我也想删除一些值



例如:



我有一个字符串 - >> AB,BC,.2584kG



在上面的字符串中我想分裂,在结果中我只想要数字值.2584不kg字符串

How to split the string and get specific value in the result string and also i want to remove some value

for eg:

I have a string this ->> AB , BC , .2584kG

In the above string i want to splt and in the result i want only the number value .2584 not the kg string

推荐答案

您可以使用 Mid
You can use Mid


(...)提取数字如果格式是固定的。

使用 InStr(...) InstrRev(...)用于查找字符串数字部分的位置,如果您有特定的字符串来分隔字符串中的数字,并且然后使用 Mid
(...) to extract the number if the formatting is fixed.
Use the InStr(...) and InstrRev(...) functions to find the positions of the numeric part of the string if you have specific strings that delimit the number in the string, and then use Mid


()

告诉我们可能的字符串的一般格式是(宽度已知)我们可以尝试进一步帮助。



抱歉你被困在VB6。

我的妻子已经同样的问题在她的工作。

(小公司。遗留代码。没有重写预算。)



编辑:修改以回应评论:

所以,如果字符串的开头是总是完全 AV,BC,然后它看起来像提取数字可以用:

().
Tell us what the general format of the possible strings is (with widths where known) and we can try to help further.

Sorry about you being stuck in VB6.
My wife has the same problem at her job.
(Tiny company. Legacy code. No budget for rewrite.)

revised in response to comments:
So, if the beginning of the string is always exactly "AV,BC," then it looks like extracting the number could be done with:
Dim sText as String
Dim vNumber As Double
sText = "AV,BC, 0.12345kg"
vNumber = Val(Mid


这篇关于拆分字符串并获取值并删除Visual Basic 6.0中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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