Click here to Skip to main content
15,888,286 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVB.NET - XtraReport Not responding Pin
obuli_salem5-Jun-06 4:36
obuli_salem5-Jun-06 4:36 
QuestionProblem using textbox for searching in DataGrid Pin
Syed Ali Raza5-Jun-06 4:14
Syed Ali Raza5-Jun-06 4:14 
AnswerRe: Problem using textbox for searching in DataGrid Pin
Kschuler5-Jun-06 8:46
Kschuler5-Jun-06 8:46 
GeneralRe:Thanks Pin
Syed Ali Raza5-Jun-06 12:00
Syed Ali Raza5-Jun-06 12:00 
Questionprogress bar Pin
militiaware5-Jun-06 4:09
militiaware5-Jun-06 4:09 
Questionidle system Pin
militiaware5-Jun-06 3:43
militiaware5-Jun-06 3:43 
Questionstream reader Pin
militiaware5-Jun-06 3:27
militiaware5-Jun-06 3:27 
AnswerRe: stream reader Pin
Dustin Metzgar5-Jun-06 4:02
Dustin Metzgar5-Jun-06 4:02 
First get the Office XP PIAs. Then you can use code like this:

Imports System.Text.RegularExpressions
Imports Microsoft.Office.Interop.Word

Public Shared Function ReadFile(ByVal filename As String) As String
   Dim app As ApplicationClass = Nothing
   Dim objFilename As Object = CType(filename, Object)
   Dim readOnly As Object = True
   Dim isVisible As Object = False
   Dim missing As Object = System.Reflection.Missing.Value
   Try
      app = New ApplicationClass()
      Dim doc as Document = app.Documents.Open(objFilename, missing, readOnly, missing,
         missing, missing, missing, missing
         missing, missing, missing, isVisible,
         missing, missing, missing)
      doc.Activate()
      Dim text As String = doc.Content.Text
      Return StripText(text)
   Catch
      Throw
   Finally
      If Not(app Is Nothing)
         app.Quit(missing, missing, missing)
      End If
   End Try
End Function

Public Shared Function StripText(ByVal str As String) As String
   Dim re as Regex = New Regex("[^a-zA-Z_0-9.?\-\(\)\\\/\:\;\""\'\,\s]")
   str = re.Replace(str, "")
   re = new Regex("\s+")
   str = re.Replace(str, " ")
   Return str
End Function


I'm a C# programmer so I'm a little rusty on VB. Anyways, you use doc.Content.Text to get the raw text from the document. There will be a lot of weird characters mixed in there, hence the regular expressions. There's probably a better regular expression, I just haven't had the time. What I've found is that this gives me just the text of the document and nothing else.

QuestionMSHflexgrid and images question Pin
Tarek Jabri5-Jun-06 3:01
Tarek Jabri5-Jun-06 3:01 
Questionplease help me sm the chlbx items,pleeease Pin
nellyvb.net5-Jun-06 2:20
nellyvb.net5-Jun-06 2:20 
AnswerRe: please help me sm the chlbx items,pleeease Pin
Rey99995-Jun-06 2:38
Rey99995-Jun-06 2:38 
QuestionTextBox language !! Pin
Tamimi - Code5-Jun-06 1:07
Tamimi - Code5-Jun-06 1:07 
QuestionCatch an event from another form Pin
Rey99995-Jun-06 0:05
Rey99995-Jun-06 0:05 
AnswerRe: Catch an event from another form Pin
Robert Rohde5-Jun-06 0:18
Robert Rohde5-Jun-06 0:18 
GeneralRe: Catch an event from another form Pin
Rey99995-Jun-06 2:20
Rey99995-Jun-06 2:20 
GeneralRe: Catch an event from another form Pin
arcticbrew6-Jun-06 9:41
arcticbrew6-Jun-06 9:41 
QuestionBrowser Pin
Socheat.Net4-Jun-06 22:58
Socheat.Net4-Jun-06 22:58 
QuestionFinding maximum value from a series... Pin
mayhem_rules4-Jun-06 22:56
mayhem_rules4-Jun-06 22:56 
AnswerRe: Finding maximum value from a series... Pin
Tamimi - Code4-Jun-06 23:44
Tamimi - Code4-Jun-06 23:44 
GeneralRe: Finding maximum value from a series... Pin
mayhem_rules5-Jun-06 0:02
mayhem_rules5-Jun-06 0:02 
GeneralRe: Finding maximum value from a series... Pin
Robert Rohde5-Jun-06 0:13
Robert Rohde5-Jun-06 0:13 
GeneralRe: Finding maximum value from a series... Pin
mayhem_rules5-Jun-06 0:23
mayhem_rules5-Jun-06 0:23 
AnswerRe: Finding maximum value from a series... Pin
Guffa5-Jun-06 0:47
Guffa5-Jun-06 0:47 
GeneralRe: Finding maximum value from a series... Pin
mayhem_rules5-Jun-06 1:14
mayhem_rules5-Jun-06 1:14 
AnswerRe: Finding maximum value from a series... Pin
J4amieC6-Jun-06 0:00
J4amieC6-Jun-06 0:00 

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.