如何根据VB .NET中的选择将数字1添加到32位字符串 [英] How to add number 1 to a 32 bit character string based on selection in VB .NET

查看:89
本文介绍了如何根据VB .NET中的选择将数字1添加到32位字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB .net并将第三方dll集成到我的代码中,该代码与酒店软件中的密钥卡相关。



因此生成密钥卡对于特定楼层的客人办理登机手续。因为在他们的文件中他们要求将其格式化为32位字符串。



例如:如果客人在17岁地板然后



I am using VB .net and integrating the third party dll to my code which is related to keycard in Hotel software.

So the key-card is generated for the particular floor the guest check in. for that in their documentation they asked to format it as 32 bit character string.

Ex: If the guest is in 17 the floor then the

Dim FloorSelection as string = "00000000000000010000000001000000"





从左边1应该添加到每层7的位置,1应该添加到客人签到的楼层



什么我试过了:



所以我怎么能根据他们的标准来实现这一点,根据客人入住楼层



From left 1 should be added in place of 7 for each floor and 1 should be added to the floor the guest checkin

What I have tried:

so how can i achieve this based on their criteria to add 1 to the particular place based on the guest check in floor

推荐答案

从这个例子中说出来并不容易 - 你真的需要回到文档并仔细检查它应该如何重新生成字符串迟到的地板和房间号码,因为它看起来不太可能。

最佳猜测:

It's not easy to tell from just that one example - you really need to go back to the documentation and double check exactly how the string it supposed to relate to the floor and room number, as it seems unlikely that it's what it appears from that.
Best guess:
00000000000000010000000001000000

分为两部分:

Is in two parts:

0000000000000001  -  floor number (1)
0000000001000000  -  room on floor (7)

但是这限制了系统只能在每层16个房间工作,而且我已经住在远远不止的酒店!



但这种转换的最简单方法是设置一个数组:

But that restricts the system to only work with 16 rooms per floor, and I've stayed in hotels with far, far more than that!

But the simplest way to do this conversion is to set up an array:

Private toBinaryString As String() = {"0000000000000001", "0000000000000010", "0000000000000100", "0000000000001000", "0000000000010000", "0000000000100000", "0000000001000000", "0000000010000000", "0000000100000000", "0000001000000000", "0000010000000000", "0000100000000000", "0001000000000000", "0010000000000000", "0100000000000000", "1000000000000000"}

然后使用楼层号码和房间号码作为索引,以获得所需字符串的每个一半。



但我强烈建议您在提交之前仔细阅读文档你自己!

and then use the floor number and room number as indexes to get each "half" of the string you need.

But I'd strongly advise you to read the documentation carefully before committing yourself on this!


这篇关于如何根据VB .NET中的选择将数字1添加到32位字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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