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
Solved

VB6 - Remove letters nd empty spaces in column grid

Posted on 2013-01-26
4
449 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…

839 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