Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / October 2004



Tip: Looking for answers? Try searching our database.

Visual Basic to proC.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kenneth Osenbroch - 28 Oct 2004 21:25 GMT
Hi,

Can anyone help me translate the following Visual Basic code to proC?

   Dim iCounter As Integer
   Dim iSum As Integer
   Dim iMultiplier As Integer
   
   iMultiplier = 7
   
   For iCounter = Len(sReference) To 1 Step -1
       iSum = iSum + Val(Mid(sReference, iCounter, 1)) * iMultiplier
       If iMultiplier = 7 Then iMultiplier = 3 Else If iMultiplier =
3 Then iMultiplier = 1 Else If iMultiplier = 1 Then iMultiplier = 7
   Next
   
   fReferenceCheckSum = Right(Str(10 - (iSum Mod 10)), 1)
End Function

Thanks,
Kenneth
Frank Adam - 29 Oct 2004 00:35 GMT
>Can anyone help me translate the following Visual Basic code to proC?

I assume proC is C of some sort ?

Try this. Warning, not tested and done on the fly without thinking.

int SomeFuncToGetaCheckSum(void)
{
    int iCounter;
    int iSum;
    int iMultiplier = 7;
    char sTemp[20];
    char *p = sReference;
   
    while (p && *p)
    {
         if (isdigit(*p)
        {
        iSum += ((*p) - 48) * iMultiplier;
            switch(iMultiplier)
            {
            case 7 : iMultiplier = 3; break;
            case 3 : iMultiplier = 1; break;       
            case 1 : iMultiplier = 7;
            }
        } /* end isdigit */
    p++;
    } /* end while */

    iSum %= 10;
    iSum -= 10;
    _itoa(iSum,sTemp,10);
    fReferenceCheckSum = &sTemp[strlen(sTemp) -1];
    return fReferenceCheckSum;
}

I think that may do something close. Or not. :)

Signature

Regards, Frank

Mike Williams - 29 Oct 2004 10:47 GMT
> Warning, not tested and done on the fly without thinking.

So what's new ;-)

Mike
Frank Adam - 29 Oct 2004 15:16 GMT
>> Warning, not tested and done on the fly without thinking.
>
>So what's new ;-)

LOL. I meant without drinking. ;-)
No, i meant without actually looking at the problem, it was just a
line by line conversion.

Signature

Regards, Frank

Kenneth Osenbroch - 30 Oct 2004 09:11 GMT
> >Can anyone help me translate the following Visual Basic code to proC?
> >
[quoted text clipped - 33 lines]
>  
> I think that may do something close. Or not. :)

Thanks Frank, I'll try it.

Cheers, Kenneth
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.