# VBA equivalent to GWBASIC's MKI\$ ?

In GWBasic MKI\$ is used to store an integer value to a string, encoding it in the process.

I am trying to convert the following GWBASIC code to Access 97, but can't find an equivalent to MKI\$

Open "R",#1,"TESTING",2
Field #1, 2 as Bitt\$
Lset Bitt\$ = MKI\$(64)  ' Convert the number 64 to a string
Put #1, 1 ' place at record position 1

------- taken from online GWBASIC help file -------
MKI\$, MKL\$, MKQ\$, MKS\$, MKD\$, MKE\$, MKF\$, MKB\$, MKBYT\$, MKWRD\$, MKDWD\$
----------------------------------------------------------------------
Purpose:  This function converts numeric data into a string for random access file output

Syntax:   s\$ = MKI\$(integer expression)
s\$ = MKL\$(long integer expression)
###### Who is Participating?

Commented:
You could write your own equivalent function ... something like:

Function MyMKI (MyInt as integer) as string
MyMKI = CHR\$(MyInt / 256) & CHR\$(MyInt MOD 256)
End Function

You might have to tweak this code a bit.  I didn't test is.
0

Commented:
You can use CStr(int).

dim iLoop as integer
dim sLoop as string

sLoop = cstr(iLoop)

0

Author Commented:
CStr is NOT an equivalent to GWBasic's MKI\$

MKI\$ and all the MK*\$ functions ENCODE a numeric value to a string.  E.g.

A\$ = MKI\$(1234)

would cause A\$ to equal Chr(209)+Chr(4)

IOW, it takes a 4 digit integer and converts it to a two digit string.

CStr, on the other hand, converts 1234 to "12" if A is a 2 character string value, chopping off the "34".

This is not acceptable.
0

Commented:
EE saved my butt.  Found this by a search.

A follow up if any of you are still around - what would be the function for any of the other MKx functions?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.