|
Do NOT post similar questions more than once right next to each other in the same forum. Along with that you should also use the code blocks to make your messages more readable.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
here is my code
Imports System.IO.File
Imports sqld
Public Class Form1
Private ob1 As sqld.sqld.sqldb
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
ob1 = New sqld.sqld.sqldb()
' Add any initialization after the InitializeComponent() call.
End Sub
Private WordApp As New Word.ApplicationClass()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "Word Documents|*.doc"
txtFileName.Text = OpenFileDialog1.FileName
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim WordApp As New Word.ApplicationClass()
Dim file As Object = OpenFileDialog1.FileName
'Dim wdLineType1 As Word.WdLineType = Word.WdLineType.wdTextLine
Dim nullobj As Object = System.Reflection.Missing.Value
Dim doc As Word.Document = WordApp.Documents.Open(file, nullobj, nullobj, nullobj, nullobj, nullobj, _
nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, _
nullobj, nullobj, nullobj)
doc.Activate()
'Dim st As System.Type
'st = wdLineType1.GetType
'Dim doc1 As Word.Document = WordApp.ActiveDocument
Label2.Text = doc.Range(0, 9).Text
' Label2.Text += " " + doc.'wdLineType1.GetValues(st).GetValue(1).ToString
'Dim m_Content As String = doc1.Content.Text
'Label2.Text = m_Content
'doc.ActiveWindow.Selection.WholeStory()
'doc.ActiveWindow.Selection.Copy()
'Dim data As IDataObject = Clipboard.GetDataObject()
''Do whatever with the text.
'Label2.Text = data.GetData(DataFormats.StringFormat)
'Close doc and shutdown Word application.
doc.Close(nullobj, nullobj, nullobj)
WordApp.Quit(nullobj, nullobj, nullobj)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim temp As String = Label2.Text.ToString()
Dim ch As Char() = {":"}
Dim str1 As String() = Label2.Text.Split(ch)
Try
For i As Integer = 0 To str1.GetUpperBound(0)
'MessageBox.Show(str1(3).ToString())
'Dim str22 As String = ob1.insertNData(str1(1), str1(3), str1(5), str1(7)).ToString()
i = i + 1
Next
Catch ie As IndexOutOfRangeException
ie.ToString()
End Try
End Sub
End Class
in my word document four lines
i need to cut each line
how can i read word document line by line
please
help
|
|
|
|
|
hi i've created a form which edit & diaplayes data into a data grid..
when i save data through Save button click data gets saved but if i (after entering 3-4 records) press shortcut key as <Alt + S> last record from the data grid not get saved .. even this is not displayed in the datasource during debug ...
i added a code because datagrid doesnt displayed next column without hitting the keys on last column...
If dgdcoccmast(dgdcoccmast.CurrentCell.RowNumber, 0).ToString <> "" Then
Dim cm1 As CurrencyManager = Me.BindingContext(Me.dgdcoccmast.DataSource)
cm1.EndCurrentEdit()
End If
but the problem remains....
Please help
|
|
|
|
|
What code did you write to make this shortcut key work ? How has the debugger led you to believe that it should be saving ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Sir,
its not the shortcut key code since this shortcut is just to focus the Save button '&Save' event is firing is the btnSave_click only.. but in the datatable which i m using & binding to datagrid is not considering the last record because user is not hitting any key to generate the new row in the datagid instead it just saving the data....
|
|
|
|
|
OK, so you need to write code that detects that a record has not been saved, based on key presses in the grid ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
No i just need to write a code which saves all the records edited or added new in the grid on the pressing of Alt + s keys
|
|
|
|
|
OK, so the code issue IS that you are pressing a key and you didn't write code to make it do anything ? I am confused....
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
dont get confused... Sorry if i am unable to explain u properly well i had found the solution...
thanks for ur support & invaluable time...
|
|
|
|
|
Public Class Form1
Delegate Sub d(ByVal b As Boolean, ByVal b1() As Button)
Private Sub disablefunction(ByVal val As Boolean, ByVal ParamArray b() As Button)
For i As Integer = 0 To b.Length - 1
b(i).Enabled = val
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Invoke(New d(AddressOf disablefunction), False, Button1, Button2)
End Sub
End Class
</pre>
I am getting the following error
Parameter count mismatch
|
|
|
|
|
It's sure VERY nasty that you're passing controls arround, but does ParamArray mean you can pass as many buttons as you like, or do you need to create the array and pas it ?
Is that really how you call a delegate in VB ? It looks nasty compared to C#
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Pretty sure ParamArray is the equivalent of the C# params keyword. Regardless, his delegate signature is d(bool, Button) and he's calling it with two Buttons...
|
|
|
|
|
Christian Graus wrote: Is that really how you call a delegate in VB ? It looks nasty compared to C#
Not exactly. He's doing Me.Invoke, which would call a method on the main thread. From what I know, the same thing in C# would be (note that I've also fixed his problem here):
this.Invoke((d)disablefunction, false, new button[] {Button1, Button2})
|
|
|
|
|
ParamArray only works when you are directly calling the function. The arguments passed to a ParamArray parameter will always be converted to an array at compile time. When you are using Me.Invoke, you need to make the array yourself.
Me.Invoke(New d(AddressOf disablefunction), False, new Button() {Button1, Button2})
As a bonus, if you had declared the function as
disablefunction(ParamArray b() as object)
and called it as
disablefunction(new button() {Button1, Button2})
you would get a one element array that is an array of buttons.
|
|
|
|
|
Good day fellow codeproject.com'ers.
I am missing a vital part of theory which I've identified when I tried the below. (I believe it's theory...)
Please can one of you assist me by filling the theory gap I have. I've been through MSDN and Google, but to no avail...
Question:
Why can one not call a class from within another class? I don't mean within a function of a class, but at the top, where one declares variables pertaining to that class.
E.g. Below:
Friend Class Class1
Dim _message As String
Public Property Message()
Get
Return _message
End Get
Set(ByVal value)
_message = value
End Set
End Property
End Class
And here is where it fails, intellisense doesn't see the properties or methods of the variable (first class), I've labled the variable as THISDOESNTWORK.
Friend Class Class2
Dim _myVariable As String
Dim THISDOESNTWORK as New Class1
Public Property myVariable()
Get
Return _message
End Get
Set(ByVal value)
_message = value
End Set
End Property
End Class
It works when I place the code
Dim THISDOESNTWORK as New Class1<br /> within a function, so either there is a "secret way to do this", or I'm missing a bit of .Net/OOB Theory.
Thanks in advance...
|
|
|
|
|
class2 needs to be like this
Friend Class Class2
Dim _myVariable As String
Dim THISDOESNTWORK As New Class1
Public Property myVariable()
Get
Return THISDOESNTWORK.Message
End Get
Set(ByVal value)
THISDOESNTWORK.Message = value
End Set
End Property
End Class
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Thank you!
Ah, a blonde moment of note!
This one will definatly go down in the books a silly moment for me, hopefully this helps someone else
Thanks again.
- Artificial intelligence is no match for natural stupidity
|
|
|
|
|
It should also be mentioned that your syntax might be a bit off:
Friend Class Class2
Dim _myVariable As String
Dim THISDOESNTWORK as New Class1
Public Property myVariable()as string
Get
Return THISDOESNTWORK._message
End Get
Set(ByVal value as string)
THISDOESNTWORK._message = value
End Set
End Property
End Class
or
Friend Class Class2
Dim _myVariable As String
Dim THISDOESNTWORK as New Class1
Public Property myVariable() as Class1
Get
Return THISDOESNTWORK
End Get
Set(ByVal value as Class 1)
THISDOESNTWORK= value
End Set
End Property
End Class
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
I have web-pages & MS Access database in my web-host (http://www....), is there easy way to use VB.net to access it without using FTP?
If possible, please provide valid links or sample codes.
Thanks
|
|
|
|
|
where is the access file in relationship to your vb.net code? why does ftp come into play?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Please see the comments on Can I use VB.net and XML to read/write a MS access database in the web-site? about 2 pages after this page.
I post 2 questions because the first one I mentioned about using XML ... but what I try to find out which is the best way to write/read MS Access database in my Web-host! How do you think?
|
|
|
|
|
I need to find out how to do the following:
I have a script to do this
Ask User for a variable
Create a NEW sheet with the variable name
I am able to do some of the above however I need to incorporate some error checking to prevent the script failing. wats the best course of action
hope this makes sense to someone
|
|
|
|
|
Is this a question about VB scripting in MS Excel?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
|
Ok - I guess you need to check for 2 things:
1) Check that the user input is valid (not blank, doesnt contain invalid characters...)
2) Check that the name specified does not already exist as another sheet in the workbook where you want to attempt to create the new sheet (Check the Workbook.Sheets collection)
HTH
|
|
|
|