Solved

User defined mapping?

Posted on 2000-03-24
4
153 Views
Last Modified: 2010-05-02
This is my current code, it works fine, but I need to add another element which I don't know how to go about it.  As you can see below,
txtLocation(0).text = Trim(Mid(strBuff, 342, 9))
txtLocation(1).text = Trim(Mid(strBuff, 424, 9))
and so on .... txtLocation(15)

Except, that I do not always want txtLocation(0).text = Trim(Mid(strBuff, 342, 9)).  It could equal any one of the 16 values.  A user would decide which values goes with which txtLocation.

The user input would come from from2, where there are 16 boxes called txtUserDefinedLocation(index).text

Thus if txtUserDefinedLocation(0).text =1 Then txtLocation(0).text = Trim(Mid(strBuff, 424, 9))


-------------------Code-----------------
Private Sub RefreshScreen1()

Dim strBuff As String
strBuff = Display.Contents

Dim i As Integer
Dim x As Integer

x = 342
For i = 0 To 15

txtLocation(i).Text = Trim(Mid(strBuff, x, 9))
     
x = x + 82

Next
End Sub

----------------End of Code------------

Thanks much
0
Comment
Question by:ptran2000
[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
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
PatrickVD earned 153 total points
ID: 2655675
Hi,

Actually, if your interval between all the elements is always 82.
I am assuming that the numbering in 1-based, and not zero-based as the array element indexes are.

Here's an updated function for you :

-------------------Code-----------------
Private Sub RefreshScreen1()

Dim strBuff As String
strBuff = Display.Contents

Dim i As Integer
Dim x As Integer
Dim iItemNr As Integer

x = 342
For i = 0 To 15
  iItemNr = CInt(txtUserDefinedLocation(i).Text) - 1
  txtLocation(i).Text = Trim(Mid(strBuff, (x + (iItemNr * 82)), 9))

Next
End Sub

----------------End of Code------------

In order to have it bulletbroof, you should first validate ALL the txtUserDefinedLocation text boxes for valid numeric input within the correct range (1 to 16)


Hope this helps.

0
 
LVL 14

Expert Comment

by:mcrider
ID: 2655678
I'm not sure I get this, but is this what you're looking for??

Private Sub RefreshScreen1()

Dim strBuff As String
strBuff = Display.Contents

Dim i As Integer
Dim x As Integer

x = 342
For i = 0 To 15

txtLocation(i+1).Text = Trim(Mid(strBuff, x, 9))
       
x = x + 82

Next
End Sub

This would fill txtLocation(1) thru txtLocation(16) and not fill txtLocation(0)...

If this is not what you're looking for, please explain further...


Cheers!®©


0
 

Author Comment

by:ptran2000
ID: 2655755
wouhou!  You got it PatrickVD!

Thanks a lot!
0
 
LVL 1

Expert Comment

by:PatrickVD
ID: 2655778
Thanks for the compliment ptran2000 !
If happen to visit Belgium some day, you'll buy me a drink on this one ! ;-)

Happy coding,

Patrick.
0

Featured Post

Technology Partners: 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 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