Solved

VB6 - Transfer cell from MSFlexgrid into TEXTbox

Posted on 2013-12-07
8
518 Views
Last Modified: 2013-12-07
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

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
  • 3
  • 3
  • 2
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39703051
Your code should work. Don't forget to set the Multiline property of the text box to True.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 39703053
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
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39703078
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

0
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!

 
LVL 11

Author Comment

by:Wilder1626
ID: 39703085
Hi MartinLiss

Sorry but still same result

Here is a draft example.
Form1.zip
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 39703091
This is one way:
    Dim clone As Long
    For clone = 2 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(clone, 1) <> "" Then
            If Len(clone_store) = 0 Then
                clone_store = MSHFlexGrid1.TextMatrix(clone, 1)
           Else
                clone_store = clone_store & vbCrLf & MSHFlexGrid1.TextMatrix(clone, 1)
           end if
        End If
    Next clone

Open in new window


Edit. Missing End If inserted
0
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 39703116
Private Sub Transfer_Click()
    'clone_store
    Dim clone As Long
  For clone = 0 To MSHFlexGrid1.Rows - 1
        If Trim(MSHFlexGrid1.TextMatrix(clone, 1)) <> "" Then ' no spaces between the quotes
            If clone = 0 Then
                clone_store = MSHFlexGrid1.TextMatrix(clone, 1)
            Else
                clone_store = clone_store & vbCrLf & MSHFlexGrid1.TextMatrix(clone, 1)
            End If
        End If
    Next clone
End Sub

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 39703123
Thanks a lot for your help

It all works.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39703126
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
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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

751 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