Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB guy needs help with real code. 1

Status
Not open for further replies.

woyler

Programmer
Jun 20, 2001
678
US
Hi all,
I have a snipet of C code I need a little translation on. I only know a small amount of C or ++ so I am kind of stuck. I understand that there are some values assigned in the code that you cant see because it is missing, but I am hoping that you can do you best. My main focus is what occurs with the sprintf call. Any help at all would be greatly appreciated. Here is the code:

void IS_NewPalletNumber( char PalletNumber[] )
{
int PalletSeed;

static char GrafTable[] = "0123456789ABCDEFGHJKLPQRTUVYX#";

if ( LogSettings.PalletNumber >= IS_MaxPalletNumber ) {
LogSettings.PalletNumber = 0;
}/*if*/

PalletSeed = LogSettings.PalletNumber;

/* Keep the pallet numbers unique between 10 machines */
PalletSeed += ((MachineNumber-1) * 2000);

sprintf( PalletNumber,"%c%03d",
GrafTable[10+(PalletSeed/1000)], PalletSeed % 1000 );

LogSettings.PalletNumber++;
}/* IS_NewPalletNumber */

Thanks again,
Bill
 
Something like

Function IS_NewPalletNumber() As String

Dim GrafTable As String

GrafTable = "0123456789ABCDEFGHJKLPQRTUVYX#"
.
.
.
.
IS_NewPalletNumber = Mid$(GrafTable,_
10 + (PalletSeed \ 1000) + 1, 1) _
& Format$(PalletSeed Mod 1000, "000")

End Function

Note the integer divide and adding 1 to the indexing into GrafTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top