Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# VBA equivalent to GWBASIC's MKI\$ ?

Posted on 1998-08-28
Medium Priority
398 Views
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)
0
Question by:Softtech
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 1

Expert Comment

ID: 1960619
You can use CStr(int).

dim iLoop as integer
dim sLoop as string

sLoop = cstr(iLoop)

0

Author Comment

ID: 1960620
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

Accepted Solution

schwedm earned 150 total points
ID: 1960621
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

LVL 7

Expert Comment

ID: 3031219
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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
###### Suggested Courses
Course of the Month12 days, 4 hours left to enroll