Solved

Pls help translate to VB

Posted on 2006-06-23
2
334 Views
Last Modified: 2008-02-01
I can't seem to get these two functions into VB

private void button1_Click(object sender, System.EventArgs e)
{
// clear this book
this.c1XLBook1.Clear();

// copy range from other books
CopyRange(@"c:\temp\book1.xls", 0, 0, 66, 10, 0);
CopyRange(@"c:\temp\book2.xls", 0, 0, 66, 10, 66);
CopyRange(@"c:\temp\book3.xls", 0, 0, 66, 10, 66+66);

// save and show the result
string fileName = @"C:\temp\test.xls";
c1XLBook1.Save(fileName);
System.Diagnostics.Process.Start(fileName);
}

private void CopyRange(string fileName, int r1, int c1, int r2, int c2,
int targetRow)
{
// get source sheet
C1XLBook book = new C1XLBook();
book.Load(fileName);
XLSheet src = book.Sheets[0];

// get destination sheet
XLSheet dst = this.c1XLBook1.Sheets[0];

// copy the values
for (int r = r1; r <= r2; r++)
{
for (int c = c1; c <= c2; c++)
{
dst[targetRow + r - r1, c].Value = src[r, c].Value;
}
}
}
0
Comment
Question by:RonaldZaal
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 16970576
Try...

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    ' clear this book
    Me.c1XLBook1.Clear()

    ' copy range from other books
    CopyRange("c:\temp\book1.xls", 0, 0, 66, 10, 0)
    CopyRange("c:\temp\book2.xls", 0, 0, 66, 10, 66)
    CopyRange("c:\temp\book3.xls", 0, 0, 66, 10, 66 + 66)

    ' save and show the result
    Dim fileName As String = "C:\temp\test.xls"
    c1XLBook1.Save(fileName)
    System.Diagnostics.Process.Start(fileName)
End Sub

Private Sub CopyRange(ByVal fileName As String, ByVal r1 As Integer, ByVal c1 As Integer, ByVal r2 As Integer, ByVal c2 As Integer, ByVal targetRow As Integer)
    ' get source sheet
    Dim book As New C1XLBook()
    book.Load(fileName)
    Dim src As XLSheet = book.Sheets(0)

    ' get destination sheet
    Dim dst As XLSheet = Me.c1XLBook1.Sheets(0)

    ' copy the values
    For r As Integer = r1 To r2
        For c As Integer = c1 to c2
            dst(targetRow + r - r1, c).Value = src(r, c).Value
        Next c
    Next r
End Sub
0
 
LVL 5

Author Comment

by:RonaldZaal
ID: 16983688
Many thanks for helping me out here.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

22 Experts available now in Live!

Get 1:1 Help Now