Solved

user defined mapping question?

Posted on 2000-03-27
2
161 Views
Last Modified: 2012-05-04
Now essentially,

txtName(0) = 499
txtName(1) = 581
....
txtName(16) =539
....

Great, now I need to add that other element that I mentioned before.  Essentially, I want a user to have the option to "remapped" what value goes to what text box"  Thus a users could decide that 539 could be displayed in txtName(2).text.  I added another array of 32 textboxes called txtUserDefinedLocation to accommodate this element.  See code and modifed code below.


'-----------Current code-------------

  Dim i As Integer
   
  For i = 0 To 31
    If i < 16 Then
      txtName(i).text = 499 + i * 82
    Else
      txtName(i).text = 539 + (i - 16) * 82
    End If
  Next
'------------Modified code------------
Dim i As Integer
Dim iItem As Integer
   
  For i = 0 To 31
    If i < 16 Then
iItemNr = CInt(txtUserDefinedLocation(i).Text) - 1
      txtName(i).text = 499 + iItemNr * 82
    Else
iItemNr = CInt(txtUserDefinedLocation(i).Text) - 1
      txtName(i).text = 539 + (iItemNr - 16) * 82
    End If
  Next

' ----------end of modified code-----
Can someone tell me what is wrong with the modifed code, it only works it when txtUserDefinedLocation(0 To 15).text =1 To 16.  and when

txtUserDefinedlocation(16-31).text = 16 To 32

But
txtUserdefinedLocation(0-31) should be able to accept 1 To 32

Or is there a better way to do this.  




   



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 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 65 total points
ID: 2661664
Not sure I understand correctly, is this what you mean?

Dim i As Integer
Dim iItem As Integer
   
  For i = 0 To 31
iItemNr = CInt(txtUserDefinedLocation(i).Text) - 1
      If iItemNr < 16 Then
      txtName(iItemNr).text = 499 + iItemNr * 82
      Else txtName(iItemNr).Text = 539 + (iItemNr - 16) * 82
      End If
  Next



0
 

Author Comment

by:ptran2000
ID: 2661715
For some reason i changed txtName(iItemNR) to txtName(i) and it worked,

thanks


Dim i As Integer
Dim iItem As Integer
     
  For i = 0 To 31
iItemNr = CInt(txtUserDefinedLocation(i).Text) - 1
      If iItemNr < 16 Then
      txtName(i).text = 499 + iItemNr * 82
      Else txtName(i).Text = 539 + (iItemNr - 16) * 82
      End If
  Next

0

Featured Post

Industry Leaders: 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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

737 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