Solved

VB6 - Remove letters nd empty spaces in column grid

Posted on 2013-01-26
4
446 Views
Last Modified: 2013-01-26
Hello all

I would like to remove all letters in column 47 of my grid starting at row 1.

Once all letters removed from each cells, it would trim the data also to remove empty spaces before and after the value left in the cell. Normally numbers of the cell would be empty.

How can i do that please?

Thanks again

For grid_cust = 1 To MSHFlexGrid1.Rows - 1
        MSHFlexGrid1.TextMatrix(0, 30) = "CONCATENATE_FIELD"
        If MSHFlexGrid1.TextMatrix(grid_cust, 1) <> "" And MSHFlexGrid1.TextMatrix(grid_cust, 1) = "CUSTOMER" Then
            MSHFlexGrid1.TextMatrix(grid_cust, 47) 'remove all letters and also TRIM what's left
        End If
    Next grid_cust	

Open in new window

0
Comment
Question by:Wilder1626
  • 2
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38822642
"remove all letters" means keep all digits/numbers  and/or special characters?
you could create such a function "remove_letters", and use it...
you could use this "function" here:http://www.codeguru.com/vb/gen/vb_misc/text/article.php/c2739/Removing-Characters-and-Strings-from-a-String-VB6.htm
and use the "abcdefg...." etc string ...
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 38822689
Hi
I just tried like this but it removes even the numbers from the cell now.

    Public Function StripOut(From As String, What As String) As String
     
    Dim i As Integer
     
    StripOut = From
    For i = 1 To Len(What)
    StripOut = Replace(StripOut, Mid$(What, i, 1), "")
    Next i
     
    End Function



Private Sub test222_Click()
 Dim grid_cust As Long
    Dim C As Long
    Dim r As Long
    Dim cell_wid As Single
    Dim col_wid As Single

For grid_cust = 1 To MSHFlexGrid1.Rows - 1
        MSHFlexGrid1.TextMatrix(0, 30) = "CONCATENATE_FIELD"
        If MSHFlexGrid1.TextMatrix(grid_cust, 1) <> "" And MSHFlexGrid1.TextMatrix(grid_cust, 1) = "CUSTOMER" Then
            MSHFlexGrid1.TextMatrix(grid_cust, 47) = StripOut("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
        End If
    Next grid_cust
End Sub

Open in new window

0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 38822848
MSHFlexGrid1.TextMatrix(grid_cust, 47) = StripOut("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

should be:
MSHFlexGrid1.TextMatrix(grid_cust, 47) = StripOut( MSHFlexGrid1.TextMatrix(grid_cust, 47) , "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 38822935
Thanks, this is perfect

works pretty good.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 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

21 Experts available now in Live!

Get 1:1 Help Now