473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Extract/convert string from XLS

Here is my code:


Expand|Select|Wrap|Line Numbers
  1. Option Explicit On
  2. Option Strict Off
  3. Imports System.IO
  4. Imports System.Text
  5. Public Class Form1
  6. Public moApp As Object
  7.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  8.         Try
  9.             moApp = CreateObject("Excel.Application")
  10.             moApp.Visible = False
  11.         Catch ex As Exception
  12.             MessageBox.Show(ex.Message, "VB/Office Guru™ Excel Late Binding VB.NET Automation FAQ", _
  13.             MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  14.         End Try
  15.     End Sub
  16.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  17.     Dim oWB As Object = moApp.Workbooks.Open(CurDir() & "\sample.xls")
  18.         moApp.Visible = False        
  19.     Dim listnames As String = File.ReadAllText(CurDir() & "\listofnames.txt")
  20.           Dim name as String    
  21.     name = oWB.Sheets("Sheet1").Cells(1, 1).Value
  22.     MsgBox(listanames.Contains(name))
  23. End Sub
  24. End Class
  25.  

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!
Jun 11 '12 #1

✓ answered by Marko Danilovic

Problem solved:
It turned out that in fact these "*.xls" files are copied from the HTML files that have Chr(160) instead of standard spaces...
Now the program work fine.

1 1605
Problem solved:
It turned out that in fact these "*.xls" files are copied from the HTML files that have Chr(160) instead of standard spaces...
Now the program work fine.
Jun 12 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
1
by: | last post by:
Hiya, I need to extract a string (ascii) from a buffer, my buffer is dim buf(1023) as byte This buffer containg an "array" of type xxx type xxx is defined in C as follows
3
by: Petr Jakes | last post by:
Hi, I am trying to convert string to the "escaped string". example: from "0xf" I need "\0xf" I am able to do it like: a="0xf" escaped_a=("\%s" % a ).decode("string_escape") But it looks a...
3
by: Ursula | last post by:
Is it possible to convert a string in a file. The problem is this: I have an object string that is a file xml and I want to pass to Deserialize function, but Deserialize function expect an object...
3
by: Shawn Ferguson | last post by:
Hello All, I'm trying to do what I would think would be simple and straightforward, but it is not. I have a 2 textbox on a form, a label, and a button, when I click the botton I want to add the...
1
by: nkg1234567 | last post by:
I'm trying to extract HTML from a website in the form of a string, and then I want to extract particular elements from the string using the substr function: here is some sample code that I have thus...
34
by: Umesh | last post by:
I want to extract a string abc*xyz from a text file. * indicates arbitrary no. of characters. I'm only able to do it when the string has definite no. of characters or the string length is...
4
by: Man4ish | last post by:
HI , I am trying to convert string into char array of characters.but facing problem. #include <iostream> #include <string> using namespace std; int main() { string t="1,2,3,4,5,6";
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
9
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.