Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2004, 08:54 PM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Mod operator

 am having a problem with mod in VB. Here is the problem code

Dim intKeyChar As Integer
Dim strKey As String
.
strKey = "1234"
.
intKeyChar = (i Mod Len(strKey))

The problem is that when i took this information, i = 28, and Len(strKey) = 4, so going by what i know of basic maths, 28/4 = 7, correct??? so why does intKeyChar = 0??? Is there something i have misunderstood about this operator?

-=-=-=-=-=-=-=-=-=-
LordBeholdeR
 
Old June 16th, 2004, 03:05 AM
Authorized User
 
Join Date: Aug 2003
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Mod returns the remainder of a division and 28/4 has no remainder so it is correct.

You just have to use '/' to make a division.

Regards

Tom
 
Old June 16th, 2004, 06:26 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot, atleast I have learnt something new.

-=-=-=-=-=-=-=-=-=-
LordBeholdeR





Similar Threads
Thread Thread Starter Forum Replies Last Post
having problem with Between operator anantdev SQL Language 1 May 26th, 2008 08:14 AM
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
MOD function in calculator gilgalbiblewheel Java GUI 4 September 24th, 2004 09:25 AM
Chacpter 11 MOD 2old2play BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 August 24th, 2004 02:09 PM
Mod 10 for application polj74 VB.NET 2002/2003 Basics 0 July 21st, 2004 07:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.