Solved

VBA equivalent to GWBASIC's MKI$ ?

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

738 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