Solved

Change "," with "." in MSHFlexGrid1 vb6

Posted on 2011-02-24
2
695 Views
Last Modified: 2012-05-11
Hello all,

In my code bellow, i apply a format to be "0.00". That, it work.

But what i want to add, it's this:

In the same column, search for comma ",", it there is one, put the cell in orange, and change it to a dot ".".

That, for all the MSHFlexGrid1.

How can i do that please?

Thanks again for your help.

Private Sub Command6_Click()
Dim i As Long

 
For i = 1 To MSHFlexGrid1.Rows - 1
        
        'Grids are 0 based so 0 means col1, 1 means col2, 3 means col2 and so on
        If MSHFlexGrid1.TextMatrix(i, 3) <> "" Then

            
            'Format
            
            MSHFlexGrid1.TextMatrix(i, 18) = Format(MSHFlexGrid1.TextMatrix(i, 18), "0.00")
            
            MSHFlexGrid1.TextMatrix(i, 19) = Format(MSHFlexGrid1.TextMatrix(i, 19), "0.00")
            
            MSHFlexGrid1.TextMatrix(i, 20) = Format(MSHFlexGrid1.TextMatrix(i, 20), "0.00")
            
            MSHFlexGrid1.TextMatrix(i, 21) = Format(MSHFlexGrid1.TextMatrix(i, 21), "0.00")
            
            MSHFlexGrid1.TextMatrix(i, 43) = Format(MSHFlexGrid1.TextMatrix(i, 43), "0.00")
            
            MSHFlexGrid1.TextMatrix(i, 46) = Format(MSHFlexGrid1.TextMatrix(i, 46), "0.00")
            
            MSHFlexGrid1.TextMatrix(i, 49) = Format(MSHFlexGrid1.TextMatrix(i, 49), "0.00")
            
            
        Else
            'break out of loop
            Exit For
        End If
    Next i
End Sub

Open in new window

0
Comment
Question by:Wilder1626
2 Comments
 
LVL 14

Accepted Solution

by:
VBClassicGuy earned 500 total points
ID: 34969837
In your

'Format

section, use:

txt = MSHFlexGrid1.TextMatrix(i, 3)

If Instr(txt,",") Then
   txt = Replace(txt, ",", ".")
   MSHFlexGrid1.TextMatrix(i, 3) = txt
   MSHFlexGrid1.Row = i
   MSHFlexGrid1.Col = 3
   MSHFlexGrid1.CellBackColor = &H80FF&
End If
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 34969935
Thanks for your help.

This is perfect.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

829 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