Solved

VBA equivalent to GWBASIC's MKI$ ?

Posted on 1998-08-28
4
378 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now