Solved

Fix country part 1

Posted on 2011-03-05
6
247 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 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
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!

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA : retain and exclude values based on a config sheet and multiple parameters 5 69
Add a task in Outlook from access 11 43
Spell Check in VB6 13 148
TT Auto Dashboard 13 104
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

751 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