How to add a digits to the left side of any number

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

finalOutput= Cint(“100” + var.toString)

you can provide more details if you are looking for something more than this

1 Like

Hi @vinutha1

  1. check length of the number . You can use len(‘your variable’)
  2. If length is < 5 Then Assign Variable = 100 + Variable
1 Like

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!


Thank you for the help! it was detailed explanation


Thank you so much

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.