|
How to get File's contents the txt and Doc files. so pls some one help me...
thanking you
somasundaram
|
|
|
|
|
Reading a text file is easy. There's an example here.[^]
Reading a DOC file (I'm assuming you're referring to a Word document) is not so easy. You have to use Word to open it for you. Don't even think of trying to read it directly yourself. I don't do Office Interop, so I don't have any examples to show you, but, you may want to take a look at this[^] before you start looking for an example of opening a document.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want to get the .txt and .Doc files. but i wrote the code only displaying the txt file.But it wont display the .Doc files.
I select the Doc and txt fileNames in Listbox.but File's Contents has to display in Richtextbox.
so I've written the code for(.txt) files only.But i need (.Doc) file's contents also.So How to get the (.Doc files Contents).So pls some one Help me......
Private Sub ListBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox3.SelectedIndexChanged
Dim myFile As System.IO.FileInfo
Dim fileInfo As String
Dim myFileName As String
Dim stream As StreamReader
Dim input As String
myFileName = ListBox3.SelectedItem.ToString
myFile = New System.IO.FileInfo(fileName:=myFileName)
fileInfo = myFileName.Length.ToString
stream = File.OpenText(myFileName)
input = stream.ReadLine()
Console.WriteLine(input)
RichTextBox1.Text = input
stream.Close()
End Sub
Thanking you
somasundarak
|
|
|
|
|
somagunasekaran wrote: But it wont display the .Doc files.
Of course note. The RichTextBox doesn't know anything about Word's file format.
somagunasekaran wrote: But i need (.Doc) file's contents also
You can get the text from a Word document using Office automation (Interop). But, if there is anything other than normal text in it, like tables and graphics, they won't show up in the RTB or won't show correctly.
Office automation is not something I do, so I don't have any examples to give you. But, this[^] should be a good place to start.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Private Sub BPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BPrint.Click<br />
Dim frm As New FrmPrintReport 'reports<br />
Dim cr As New CRepResponsable<br />
cr.SetParameterValue(0, Val(Me.TBAccountNumber.Text))'integer<br />
cr.SetParameterValue(1, Me.TBAccountNumber.Text)'string<br />
cr.SetParameterValue(2, vbNull) 'integer<br />
cr.SetParameterValue(3, vbNull) 'string<br />
<br />
frm.CrystalReportViewer.ReportSource = cr<br />
frm.MdiParent = Me.MdiParent<br />
frm.Show()<br />
End Sub
i have the code above. i could not pass a null parameter, to the crystal reports. i will have an empty report i tried vbnull.null and vbnull.empty same result.
but if I put
cr.SetParameterValue(2, Val(Me.TBSubAccount.Text))) 'integer 'not null<br />
cr.SetParameterValue(3, Me.TBSubAccount.Text) 'string 'not null
the report display the values.
here is the select expert formula (CR):
{CUSTOMERS.SUB_ACCOUNT_NUMBER} = {?SubAccount_String} and<br />
{ecole.serial} = {?AccountNumber} and<br />
{CUSTOMERS.ACCOUNT_NUMBER} = {?AccountNumber_String} and<br />
{ecole.sub_account} = {?SubAccount}
How could i pass a null parameter?
Regards
Ramy
|
|
|
|
|
hi ,
wish u happy new year.
i have created a setup and installed the console appln in a diffent system .Everything is working except a form which has report viewer to display output.i think i have Not follwed the procedure to create setup for applns which have reports properly.the error which is dispaly when i try to display the report using report viewer in the application is
"System.Runtime.Interopservices.com exception
(0x80040154):com object wutg cksud{...} is either not valid or not register
at crystal desicions.crystal reports.ReportDocument.[]=()
-do- .Internalinit()
-do- .ctor()
at projname.projname..ctor
at projname.frmname.btn10_click()
any suggestion is welcome...
thank you for ur time and help in advance..
enjoy..
|
|
|
|
|
Did you include in your install, or at least install seperately, Crystal Reports?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have created a rich text box using CreateWindowEx API. How do I send print of a document in the control using API or otherwise?
|
|
|
|
|
Are you sure this is a Visual Basic question ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Function RchEdtCreate(ByVal hWindow As Long, ByVal ExtendedStyle As Long, ByVal Style As Long, ByVal Text As String, ByVal xPos As Long, ByVal yPos As Long, ByVal width As Long, ByVal height As Long, ByVal hInstance As Long) As Long
LoadLibrary "riched20.dll"
Const RICHEDIT_CLASS$ = "RichEdit20A"
RchEdtCreate = CreateWindowEx(ExtendedStyle, RICHEDIT_CLASS, Text, Style, xPos, yPos, width, height, hWindow, 0, hInstance, ByVal 0&)
'RichTextWndClass, Richedit_Class, RichEdit20A
End Function
This is my Code.
|
|
|
|
|
In fact, it is plain C.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Okay Thanx,If u know the answer send it to me in any language.
|
|
|
|
|
You can use the Printer object.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Could u pls send me the source code?
|
|
|
|
|
I haven't, anyway, using the Printer object is fairly simple.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I was aware of this possibility, what I don't get is, why would you do it this way ? How does this create a different object to the one in the VB toolbox ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am trying to assign values to my array but i got an error [Object variable or With block variable not set.] May i know where i have gone wrong. Below is my codes. I hope you could assist me.
Thanks!!
Dim d As Integer = 1
Dim seq1 As Integer
Dim seq2 As Integer
Dim strseq1 As String
Dim strseq2 As String
seq1 = tb_seq1.Text.Length
seq2 = tb_seq2.Text.Length
strseq1 = tb_seq1.Text
strseq2 = tb_seq2.Text
'Loop to create array
Dim i, j As Integer
Dim F As Array
For i = 0 To seq1 - 1
F(i, 0) = d * i
Next
For j = 0 To seq2 - 1
F(0, j) = d * j
Next
|
|
|
|
|
someone_blank wrote: Dim F As Array
F = Nothing at this point
someone_blank wrote: F(i, 0) = d * i
So this will blow up.
You need to create the array with new. You'd do better to create an int array, I'd never create an instance of the Array class, that sucks. ArrayList, or List if you have VB 2005, is even better.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Thank you very much for your help.
Samantha
|
|
|
|
|
As stated by Chris, you have to use new to create instances of the arrays. Moreover, it seems you have to use jagged arrays, since, I think, seq1 , seq2 may hold different values. Look at the following MSDN sample [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello all!
i am unable to load .dsr(designer) files in vb6-Sp6.
Is it necessary to install crystal reports on my machine to work with .dsr files.
When I run VB6 and try to start a new data project I get an error to refer to datarpt.log for details - this is what the log says:
Line 2: Class {78E93846-85FD-11D0-8487-00A0C90DC8A9} of control DataReport1 was not a loaded control class.
Line 0: The file C:\bern\visbas60\Template\Projects\DataRpt.Dsr could not be loaded.
It's VB6-SP6 (brand new fresh install) - Windows XP
Any ideas?
Plz Help
Thanks!
|
|
|
|
|
Without installing Crystal Reports, how do you expect to edit one of it's Designer files?
That's the problem you're running into. Kind of like trying to open a Word document on a machine that doesn't have Word installed on it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am having trouble getting VB to interact with a MySQL server, which was setup for the purpose of keeping track of points for members of a group. The application is to display a DataGridView of an already created table which is on the MySQL server. The members would edit the table on the DataGridView, and Add or Remove a member based on a button command.
What I have read is that, by using XML, it is possible to simply connect to the database, collect the table required to display, and then disconnect (also for updating the altered data). However, since I am unable to connect to the database, the single-form layout which I had designed doesn't work. I am unable to get this to work, and have tried for weeks.
I am very lost and slightly frustrated at this. I have read every online tutorial which I can find, even other forums, etc. And still...nothing Any help will be greatly appreciated.
|
|
|
|
|
Would I be better off using MSSQL and running it from my machine?
|
|
|
|
|
|