Solved

Fix country part 1

Posted on 2011-03-05
6
234 Views
Last Modified: 2012-05-11
Hello all,

I want to be able to fix the country name in my MSHFlexGrid1.

Let me explain:

In my Grid, in the 5ft column "Origin_Reg_Key", i have multiple type of numbers. 2 of them are 5 and 8.

I need to be able to first, if there is a number 5 or 8 in column 5, then it will look at the first digit from the column 7 "Origin_Reg".

If the first character is a letter, then in column 8 "Origin_Country", it will put "CANADA". If the first character is a number, it will put "USA".

I need to do the same thing with  column 9-11-12.

How can i do this please.

Thanks
Canada-USA.bmp
0
Comment
Question by:Wilder1626
  • 3
  • 3
6 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 35059271
I wrote the following from memory of similar processing and have not tested it against any live data in a flexgrid control.  Please try it to verify (intended) results.
For lngLoop = 1 To MSHFlexGrid1.Rows
  Select Case Val(MSHFlexGrid1.Column(lngLoop, 5))
    Case 5,8
      If IsNumeric(Left$(MSHFlexGrid1.Column(lngLoop, 7), 1)) Then
        MSHFlexGrid1.Column(lngLoop, 8) = "USA"
      Else
        MSHFlexGrid1.Column(lngLoop, 8) = "CANADA"
      End If
  End Select
  Select Case Val(MSHFlexGrid1.Column(lngLoop, 9))
    Case 5,8
      If IsNumeric(Left$(MSHFlexGrid1.Column(lngLoop, 11), 1)) Then
        MSHFlexGrid1.Column(lngLoop, 12) = "USA"
      Else
        MSHFlexGrid1.Column(lngLoop, 12) = "CANADA"
      End If
  End Select
Next

Open in new window

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 35059397
Hello aikimark,

I have an error: Variable nor define on:

For lngLoop = 1 To MSHFlexGrid1.Rows

Should i put Dim lngLoop  as Integer?

If so then i have another error: Method or member of data not found:
Select Case val(MSHFlexGrid1.Column(lngLoop, 5))



0
 
LVL 45

Expert Comment

by:aikimark
ID: 35060822
Yes.  You will need to define a lngLoop variable (as long)

Yes.  That statement should have referenced the text at that location.  When I wrote that, I was referencing your problem description and was thinking in terms of columns.  I didn't adjust the statement when I added the row identifier.
Select Case val(MSHFlexGrid1.Text(lngLoop, 5))

Open in new window

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Author Comment

by:Wilder1626
ID: 35061502
I have changed for
Select Case val(MSHFlexGrid1.Text(lngLoop, 5))

But it does not want to take the .text.

It say: Wrong number of arguments or invalid property assignment.
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 35062190
the correct property is TextMatrix
Select Case val(MSHFlexGrid1.TextMatrix(lngLoop, 5))

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 35062284
Oh thank,  Now it is working great.

Thanks again for your help.

I will now create the part 2 of the post topic.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

746 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