Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB6 - Remove letters nd empty spaces in column grid

Posted on 2013-01-26
4
Medium Priority
?
455 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 143

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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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.
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…
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…
Suggested Courses

926 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