Solved

VB6 - Remove letters nd empty spaces in column grid

Posted on 2013-01-26
4
451 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
[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
  • 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 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

724 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