Expand|Select|Wrap|Line Numbers
- Option Explicit On
- Option Strict Off
- Imports System.IO
- Imports System.Text
- Public Class Form1
- Public moApp As Object
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Try
- moApp = CreateObject("Excel.Application")
- moApp.Visible = False
- Catch ex As Exception
- MessageBox.Show(ex.Message, "VB/Office Guru™ Excel Late Binding VB.NET Automation FAQ", _
- MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- End Try
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Dim oWB As Object = moApp.Workbooks.Open(CurDir() & "\sample.xls")
- moApp.Visible = False
- Dim listnames As String = File.ReadAllText(CurDir() & "\listofnames.txt")
- Dim name as String
- name = oWB.Sheets("Sheet1").Cells(1, 1).Value
- MsgBox(listanames.Contains(name))
- End Sub
- End Class
Now, the problem is when I'm import cell from "*.xls" files an try to compare with other "normal" strings, it's just don't work! Massage box is alwayse "False".
I try with simple copy/paste from xls file in inputbox and they didn't work.
But when in inputbox write the same word/name manualy without extracting it from xls cell, they work! Msgbox is now "True"
I have impression that when extract string from XLS files, the strings are not the same like he was some other type of string, some other characters.
And I was doing check's puting "msgbox(name)" on some places and it is the equal string that it is in "listnames".
Try on Google, but nothing found. I'm thanking You in Advance if You solve this enigma!