QTP - JavaTable - GetCellData - 显示带前导零的值

发布于 2024-11-14 18:12:52 字数 322 浏览 5 评论 0原文

我有 JavaTable,其值例如 1,0200,300,0003000 等。

当我使用 GetCellData(x,y) 函数检索值时,QTP 会修剪值中的前导零。它返回的结果类似于 200,3000 而不是 0200, 0003000

我需要表中的确切值来执行一些字符串比较。我无法提前知道有多少个零(如果有的话)是领先的。

如果您知道如何克服这个问题,请告诉我。

或者,如果您知道从 JavaTable 获取单元格数据的另一种方法,该方法不会修剪前导零。

提前致谢。

最好的问候
乔纳斯

I have JavaTable with values like 1,0200,300,0003000 etc.

When I use GetCellData(x,y) function to retrieve values QTP trims the leading zero's in values. It returns the result like 200,3000 instead of 0200, 0003000

I need the exact values from the table to perform some string comparison. There is no way for me in advance to know how many zeros, if any, is leading.

Please let me know if you know how to overcome this issue.

Or if you know of another way of getting the Cell Data from a JavaTable which does not trim the leading zeros.

Thanks in advance.

Best Regards
Jonas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩起发的微风 2024-11-21 18:12:52

剪贴板可能会有所帮助 - 您可以尝试使用击键来选择所有表格文本并将其复制到系统剪贴板,然后使用剪贴板 api 检索剪贴板的内容进行解析。

Set clipboard = createobject("mercury.clipboard")
text = clipboard.GetText()

或者,假设它不会使您的测试无效,您可以在字符串比较之前从预期值中删除前导零。或者,如果字段值具有固定长度,您可以在运行时确定缺少多少个零,并在字符串比较之前适当填充实际值。

The clipboard might help - you could try using keystrokes to select all and copy the text of the table to the system clipboard, and then use the clipboard api to retrieve the contents of the clipboard for parsing.

Set clipboard = createobject("mercury.clipboard")
text = clipboard.GetText()

Alternatively, assuming it does not invalidate your test, you could trim the leading zeros from your expected values prior to the string comparison. Or if the field values have a fixed length, you could determine at runtime how many zeros are missing and pad the actual values appropriately prior to the string comparison.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文