Solved

VBA equivalent to GWBASIC's MKI$ ?

Posted on 1998-08-28
4
392 Views
Last Modified: 2010-10-05
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
Comment
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
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:sfranks
ID: 1960619
You can use CStr(int).

dim iLoop as integer
dim sLoop as string

sLoop = cstr(iLoop)

0
 

Author Comment

by:Softtech
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

by:
schwedm earned 50 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

by:JimMorgan
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question