Solved

Fix country part 1

Posted on 2011-03-05
6
252 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
[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
  • 3
  • 3
6 Comments
 
LVL 46

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 46

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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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 46

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 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…
Suggested Courses
Course of the Month7 days, 1 hour left to enroll

622 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