Link to home
Start Free TrialLog in
Avatar of Wilder1626
Wilder1626Flag for Canada

asked on

VB6 - Transfer cell from MSFlexgrid into TEXTbox

Hi,

I would like to transfer all numbers from my MSHFlexgrid1 into my TextBox named clone_store so that each numbers shows one under the other.

Ex:

In MSHFlexgrid1:
1
2
3
4
5

Once in the TextBox clone_store
1
2
3
4
5


When i use the code below, it always leave an empty spaces on the first row of the textbox.

How can i fix this.

Thanks again for your help

    Dim clone As Long
    For clone = 2 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(clone, 1) <> "" Then
            clone_store = clone_store & vbCrLf & MSHFlexGrid1.TextMatrix(clone, 1)
        End If
    Next clone

Open in new window

Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Your code should work. Don't forget to set the Multiline property of the text box to True.
Avatar of Wilder1626

ASKER

Hi GrahamSkan

It work but it leaves an empty space on the first row of the textbox since the Textbox always start empty.

So what it does right now is:

----------------------

1
2
3
4
5



when it should do:

----------------------
1
2
3
4
5
Try this and if it doesn't work then please zip up and attach your project files.

Dim clone As Long
    For clone = 2 To MSHFlexGrid1.Rows - 1
        If Trim(MSHFlexGrid1.TextMatrix(clone, 1)) <> "" Then ' no spaces between the quotes
            clone_store = clone_store & vbCrLf & MSHFlexGrid1.TextMatrix(clone, 1)
        End If
    Next clone

Open in new window

Hi MartinLiss

Sorry but still same result

Here is a draft example.
Form1.zip
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot for your help

It all works.
You're welcome and I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013