Solved

user defined mapping question?

Posted on 2000-03-27
2
160 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA filters 2 66
Exit a vb6 apps when a calling it apps closes 15 52
Error with a code discussed on this page 5 33
Dinamic report to Crosstab query 9 34
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

830 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