Solved

VB6 - Transfer cell from MSFlexgrid into TEXTbox

Posted on 2013-12-07
8
500 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
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 45

Expert Comment

by:Martin Liss
Comment Utility
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
 
LVL 11

Author Comment

by:Wilder1626
Comment Utility
Hi MartinLiss

Sorry but still same result

Here is a draft example.
Form1.zip
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
Comment Utility
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 45

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
Comment Utility
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
Comment Utility
Thanks a lot for your help

It all works.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now