Finding how many characters before a point



I’m having a nightmare of a time and wondered if anyone could help. There’s probably (/hopefully) a really simple solution but I’m getting nothing.

I’m reading a number from Excel which could be a whole number (e.g. 1), a single number with a point (e.g. 1.5), or a double number with a point (e.g. 11.5).

The issue I’m having is working out when the number will have a single number or double number before the point. If the number has a point, it’ll be 16 characters long. If it doesn’t, it’ll only be 1 so I can’t do “If Length > 16” as it’ll always be 16 when I want to find out. The numbers before the point will always change, it could be 3, 43, 12, 24, anything.

Wildcards don’t work (e.g. If Variable.StartsWith("??.")…) so I’m stumped.

Can anyone offer a solution?



If you get the text in the cell as a string, you can use .IndexOf("."c) to find the index of the period. If there is no period, the returned index is -1.


Hi @Short,

Split the string value using .

Length of the char before dot

If you are using double or decimal value




Hi @arivu96, thanks for your response :slight_smile:

I’m using a string variable so tried your top way, but I’m getting an “Option Strict On disallows implicit conversions from ‘String’ to ‘Char’” error.

Hi @thediabloman, thanks for getting back to me! Worked a treat, thank you for saving me!