Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 - Transfer cell from MSFlexgrid into TEXTbox

Posted on 2013-12-07
8
Medium Priority
?
528 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 49

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
Technology Partners: 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 1000 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 49

Assisted Solution

by:Martin Liss
Martin Liss earned 1000 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 49

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…

715 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