Hi Guys,
i have a scenario where i need to add ‘100’ to the left side of the number when the number is less than 5 digits
Example: var1= 3084
i need output to be 1003084
Hi Guys,
i have a scenario where i need to add ‘100’ to the left side of the number when the number is less than 5 digits
Example: var1= 3084
i need output to be 1003084
Hello @vinutha1
not sure if that is clear to me.
if you just want to add any part to the variable, you can simply concatenate using “+” operator of VB
var=3084
finalOutput= Cint(“100” + var.toString)
you can provide more details if you are looking for something more than this
Hi @vinutha1
Hey @vinutha1! Lets go to the solution!
Step 1: I created two variables. “int_number” is the input number, which we will check if it has less than 5 digits. The variable “str_number” is an auxiliary variable, of type string, which we will use to concatenate the value “100” with the number if necessary.
Step 2: We compare the input number to see if it is less than 10000. This is because numbers starting at 10000 have 5 digits or more.
Step 3: If the number is less than 10000, we will need to add the value “100” to the left. So first we do this concatenation and store it in our auxiliary variable of type string.
Step 4: After this step, we convert the already concatenated string into an integer again to get the number.
Step 5: Analyzing the result.
Hope this helps!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.