?
Solved

VB6 - Remove letters nd empty spaces in column grid

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

741 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