Click here to Skip to main content
15,915,000 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Change System Volume in VB.net Pin
dan!sh 8-Jan-09 21:31
professional dan!sh 8-Jan-09 21:31 
Questionurgent help...please Pin
hrishiS8-Jan-09 17:18
hrishiS8-Jan-09 17:18 
AnswerRe: urgent help...please Pin
Dave Kreskowiak9-Jan-09 2:01
mveDave Kreskowiak9-Jan-09 2:01 
GeneralRe: urgent help...please Pin
hrishiS11-Jan-09 17:15
hrishiS11-Jan-09 17:15 
QuestionFunction of C++ dll in VB2005: R6034 Pin
alBasic8-Jan-09 9:50
alBasic8-Jan-09 9:50 
AnswerRe: Function of C++ dll in VB2005: R6034 Pin
EliottA8-Jan-09 10:05
EliottA8-Jan-09 10:05 
AnswerRe: Function of C++ dll in VB2005: R6034 Pin
Garth J Lancaster8-Jan-09 10:09
professionalGarth J Lancaster8-Jan-09 10:09 
QuestionGetting specific info from one excel file to another... Pin
dukefreak_218-Jan-09 9:25
dukefreak_218-Jan-09 9:25 
I need to get the account number located in cell f10, g10, and h10 of a number of excel files.
I also need to get the total $ amount located in cell H42 of a number of excel files.

I have set up the program to browse for the excel files I want the information from.
But I'm not sure how to get the data I need from them and put into another excel file.

Here is the code I have so far:

Imports System.IO
Public Class Form1

    Dim TheFile As Microsoft.Office.Interop.Excel.Workbook
    Dim SaveFile As StreamWriter
    Dim Files() As String
    '  Dim filebrowser As New FolderBrowserDialog
    Dim intAccountNumber As Integer
    Dim decTotal As Decimal


    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
        'Closes the application
        Me.Close()
    End Sub

    Private Sub btnshowthefile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnshowthefile.Click
        'Shows the spreadsheet
        TheFile = GetObject("G:\data\dr.xls")
        TheFile.Application.Visible = True
        TheFile.Windows(1).Visible = True
        TheFile.Application.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMaximized

    End Sub

    Private Sub btnbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbrowse.Click


        FolderBrowserDialog1.Description = "Select location of file"
        FolderBrowserDialog1.ShowNewFolderButton = False
        FolderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer

        'FolderBrowserDialog1.Filter = "Excel files (*.xls)|*.xls"
        FolderBrowserDialog1.ShowDialog()
        Dim fpath As String = FolderBrowserDialog1.SelectedPath()
        Dim tfiles() As String
        Dim files() As String
        Dim count As Integer
        tfiles = Directory.GetFiles(fpath)
        files = tfiles
        For count = 0 To files.Length() - 1
            ListBox1.Items.Add(files(count))
        Next


        SaveFile = File.CreateText("G:\data\dr.xls")
    End Sub

    Function findAccountNumber()

        'To find the account number
        Try

            If TheFile.Worksheets("sheet1").cells("9", "f").value = ("State") Then
                intAccountNumber = TheFile.Worksheets("sheet1").cells("10", "f").value
            Else
                intAccountNumber = TheFile.Worksheets("sheet1").cells("10", "g").value
            End If

        Catch ex As Exception
            intAccountNumber = 0
        End Try
        Return intAccountNumber

    End Function

    Function findthetotal()

        Dim intTotalSearch As Integer = 0

        'find the total
        
        Try
            For intTotalSearch = 0 To 90
                If TheFile.Worksheets("sheet1").cells(intTotalSearch, "g").value = ("Total") Then
                    decTotal = TheFile.Worksheets("sheet1").cells(intTotalSearch, "h").value
                Else
                    MessageBox.Show("Wrong")
                End If
            Next intTotalSearch
        Catch ex As Exception
            decTotal = 0
        End Try
        Return decTotal
    End Function

    Private Sub btnaccountinformation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaccountinformation.Click

        Try
            For Each item As String In Files

                findAccountNumber()
                findthetotal()

                'ListBox2.Items.Add("Account # " & intAccountNumber & " Total " & decTotal)

                ListBox2.Items.Add("Account # " & findAccountNumber() & " Total " & findthetotal())

                'To append
                TheFile.AppendFile(intAccountNumber & vbTab & decTotal & vbCrLf)
            Next
        Catch ex As Exception

        End Try


    End Sub


Thanks for any help...
AnswerRe: Getting specific info from one excel file to another... Pin
ChandraRam8-Jan-09 21:56
ChandraRam8-Jan-09 21:56 
GeneralRe: Getting specific info from one excel file to another... Pin
dukefreak_219-Jan-09 7:19
dukefreak_219-Jan-09 7:19 
QuestionCreating .exe from windows.form application Pin
Sublime3118-Jan-09 6:58
Sublime3118-Jan-09 6:58 
AnswerRe: Creating .exe from windows.form application Pin
EliottA8-Jan-09 7:19
EliottA8-Jan-09 7:19 
AnswerRe: Creating .exe from windows.form application Pin
Dave Kreskowiak8-Jan-09 7:20
mveDave Kreskowiak8-Jan-09 7:20 
QuestionHow to get checkbox inside dropdownlist ? Pin
Prasadsm8-Jan-09 0:05
Prasadsm8-Jan-09 0:05 
AnswerRe: How to get checkbox inside dropdownlist ? Pin
dan!sh 8-Jan-09 1:20
professional dan!sh 8-Jan-09 1:20 
GeneralRe: How to get checkbox inside dropdownlist ? Pin
Prasadsm8-Jan-09 2:55
Prasadsm8-Jan-09 2:55 
Questionset Windowstate [modified] Pin
neha.lad8-Jan-09 0:00
neha.lad8-Jan-09 0:00 
AnswerRe: set Windowstate Pin
Prasadsm8-Jan-09 0:19
Prasadsm8-Jan-09 0:19 
AnswerRe: set Windowstate Pin
dan!sh 8-Jan-09 0:50
professional dan!sh 8-Jan-09 0:50 
AnswerRe: set Windowstate Pin
Dave Kreskowiak8-Jan-09 1:57
mveDave Kreskowiak8-Jan-09 1:57 
QuestionHow to read datas from USB ??? Pin
JC.KaNNaN7-Jan-09 23:15
JC.KaNNaN7-Jan-09 23:15 
AnswerRe: How to read datas from USB ??? Pin
Dave Kreskowiak8-Jan-09 1:55
mveDave Kreskowiak8-Jan-09 1:55 
Questionis there a way to query print copies Pin
vbbeg7-Jan-09 19:04
vbbeg7-Jan-09 19:04 
AnswerRe: is there a way to query print copies Pin
Guffa7-Jan-09 20:46
Guffa7-Jan-09 20:46 
GeneralRe: is there a way to query print copies Pin
vbbeg7-Jan-09 20:50
vbbeg7-Jan-09 20:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.