私はVB.netを使い始めたばかりです。私のアプリケーションでは、Excel ファイルに使用されている行の正確な数が必要です 。正確な行数を取得したことはありません。いくつかのWebサイトで他のコードも試しましたが、何もしませんでした!! 誰か助けてくれませんか
こんにちは、実際に私は SQL SERVER 2008 を使用しています。このコードを試しました
Imports System.Diagnostics.Process
Imports System.IO
Imports System.Data.DataTable
Imports Microsoft.Office.Tools
Imports Excel
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim selectedFile As String = String.Empty
OpenFileDialog1.ShowDialog()
selectedFile = OpenFileDialog1.FileName
If (selectedFile IsNot Nothing) Then
ListBox1.Items.Add(selectedFile)
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim fullPath As String
Dim fileResult As String
Dim numRow As Integer
fullPath = Path.GetFullPath(ListBox1.SelectedItem)
fileResult = Path.GetFileName(fullPath)
Dim file_count As Integer = File.ReadAllLines(fullPath).Length
MsgBox(file_count)
しかし、やはりカウントが正しくありません。その理由は本当にわかりません!!