# Solved: Mod function in Visual Basic



## wolfworx (Oct 2, 2001)

I am programming a application in VB 6 (Sudoku Solver) and cannot seem to find a VB function like the MOD() function in Excel. I have bee able to create a work around using _INT((Col / 3 - .001+INT(x / 3)) * 3) _ instead of _MOD(x,3)_, but is there a VB function that does this that I have not been able to find?


----------



## cristobal03 (Aug 5, 2005)

VBA has a Mod function, and I know it's not the same language but I can't imagine a language not having a function to do modular division; since VBA and VB have the same roots, there has to be a Mod in VB. Search the help files for *division remainder* and see what you get.

Sorry this wasn't a more direct answer.

Actually, just now searching VBA's help, I guess VB uses Mod as an operator not a function. Try something like Int(x Mod 3), see if that doesn't work for you.

HTH

chris.

[edit]
Wee, my 500th post! I hope it's a useful one.
[/edit]


----------



## coderitr (Oct 12, 2003)

There is a Mod( ) function in VB6 that returns the remainder of a division operation.


----------



## wolfworx (Oct 2, 2001)

Thanks, guys. :up: It is an operator! The following works:

R = Int(num1 Mod num2)


----------

