Click here to Skip to main content
15,437,171 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm converting some programs from Visual Basic 6.0 to Python, and I'm stuck in one line in VB. Visual Basic code:

VB
bAddStart = "100"
bNoOfBytes = "94"
MeterId = 1

Data = Chr(MeterId) + Chr(3) + Chr(Val(bAddStart) \ 256) + Chr(Val(bAddStart) Mod 256) + Chr(0) + Chr(Val(bNoOfBytes))


For the function Chr() in VB I'm using chr() in Python. For the Val function, which function is similar in Python?
Posted
Updated 31-May-22 4:55am

 
Share this answer
 
v2
if we use int() function as below, you will get the perfect answer.

str_no = "12345"
no = int(str_no) * 1
print(no)
print(no + 1)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900