|
Christian Graus wrote: I don't care if people use VB.NET
It is an okay language for the curly-cue-phobics
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I am sending emails through Outlook 2003. The problem I'm having is that the message goes into the outbox, but if the user's outlook isn't open, the message just stays in the outbox. Can I some how siently start outlook, and 'send/receive' all?
Dim OutlookApplication As New Microsoft.Office.Interop.Outlook.Application
Dim OutLookMailItem As Microsoft.Office.Interop.Outlook.MailItem
Dim imailitem As Int32 = Microsoft.Office.Interop.Outlook.OlItemType.olMailItem
OutLookMailItem = CType(OutlookApplication.CreateItem(imailitem), Microsoft.Office.Interop.Outlook.MailItem)
'Set To and Subject of the email.
OutLookMailItem.Subject = cSubject
OutLookMailItem.Attachments.Add(Me.emailDirPath + fname + cExtension)
'Display MailItem and let them fill in the rest!
'
' make it modal
'
Me.Cursor = Cursors.Default
OutLookMailItem.Display(True)
|
|
|
|
|
Have you figured this out, or are you still having trouble with it?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I found the answer:
Dim oApp As Microsoft.Office.Interop.Outlook._Application = New Microsoft.Office.Interop.Outlook.Application
Dim oNS As Microsoft.Office.Interop.Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Microsoft.Office.Interop.Outlook.SyncObjects
Dim oSync As Microsoft.Office.Interop.Outlook.SyncObject
Try
' Reference SyncObjects.
oSyncs = oNS.SyncObjects
oSync = oSyncs.Item("All Accounts")
' Send and receive.
oSync.Start()
Catch ex As Exception
MessageBox.Show("oSync Error: " + ex.Message, "Error Sending Email From Outlook")
End Try
' Clean up.
oSync = Nothing
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
|
|
|
|
|
Any one here has work with the isis32.dll for the CDS/ISIS language, i have to wright a vb code with that and have same problems with one function IsisRecControlMap. that has a structure call IsisRecControl.
Thank's
Gasp
|
|
|
|
|
Never heard of it. It's also VERY unlikely you'll find anyone here who has used the library you're talking about. You'd be better off looking for a support board dedicated to the library in question.
|
|
|
|
|
Hi,
I'm trying to change the color depth of the user's monitor upon my app starting. I can't seem to find anything on the subject. I'm coding in 1.1 VB.Net framework. Any help would be great.
Thanks
|
|
|
|
|
First, your app, since it's running on a shared system with other applications, should NEVER change system-wide settings like this.
Second, why do you want to do this?
|
|
|
|
|
If you want to persist anyway, get prepared for some P/Invoking.
There isnt a function SetDisplayColorDepth() or so; instead you need access to the following
Win32 functions (below is C# syntax):
[DllImport("user32.dll")]
public static extern int EnumDisplaySettings (string deviceName,
int modeNum, ref DEVMODE1 devMode );
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(ref DEVMODE1 devMode, int flags);
for which you also would need a number of constants and the DEVMODE1 struct; then add
some C# or VB code to obtain the supported settings, find the one you want, and set it.
If you havent done P/Invoke before, dont bother. Try something simpler first.
|
|
|
|
|
Hi,
I wonder if its possible to query the tables in a dataset same as we do with the database tables!
I have loaded my dataset with almost 10 tables and now want to extract data from four of those tables to display everything in a datagrid!
But i couldn't find a way as how easily it can be done?
In other words i was just trying to avoid the SQL JOINS ... so i opted for dataset manipulations..
any help in this regard will be appreciated!!!
Thanks
|
|
|
|
|
Well, if you wanted to do it the same way as you would from SQL, you'd STILL be using the JOIN's. But since you can't do it using the same SQL syntax, no.
What's so hard about learning the JOIN clause anyway? Just learn it and get it overwith. You'll need it in the future and it's much easier than the way you want to do it now, so why wait?
|
|
|
|
|
Yeah thanks for the good advice and i have already started working with JOINs somehow .. But still are there any ways to filter data from two or more tables of a dataset using some criteria?
Also, when i have populated my datagrid with three or more tables how can i update data in all three if some changes occur in datagrid?
thanks
|
|
|
|
|
My problem is that in the program that I am writing I cannot save the changes to database after I load the tables from it.
Dim connstr As String = "provider=microsoft.jet.oledb.4.0;" & _
" DATA SOURCE = megas.mdb"
Dim sqlstr As String = " select * from megas "
Dim dtb As New DataTable
‘--------------------------------------------------------------
Private Sub btnload_Click(…) Handles btnload.Click
dtb.Clear()
Dim dataadapter As New OleDb.OleDbDataAdapter(sqlstr, connstr)
dataadapter.Fill(dtb)
dataadapter.Dispose()
dgdisplay1.DataSource = dtb
End Sub
‘-----------------------------------------------------------------
Private Sub btnsave_Click (…) Handles btnsave.Click
Dim changes As Integer
Dim dataadapter As New OleDb.OleDbDataAdapter(sqlstr, connstr)
Dim commandbuilder As New OleDb.OleDbCommandBuilder(dataadapter)
changes = dataadapter.Update(dtb)
dataadapter.Dispose()
If changes > 0 Then
MsgBox("SAVED ")
Else
MsgBox("not saved")
End If
End Sub
I load the table form the database and nothing goes wrong with this part, but when I want to save the changes and I click the save btn , that is what I get
“An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll “
What am I doing wrong? And why should I be getting this?
Thank you.
• Thanks for the previous help from Dave Kreskowiak and Naji Kotob +mackay, it really helped, especially that article.
|-|■~F~|-|■
|
|
|
|
|
The OleDb.OleDbException class is created whenever the .NET Framework Data Provider for OLE DB encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) OleDbException always contains at least one instance of OleDbError. -an explanation from msdn
--the most common cause of this is because of a missing data source
as what is written on your code:
Dim connstr As String = "provider=microsoft.jet.oledb.4.0;" & _
" DATA SOURCE = megas.mdb"
the "DATA SOURCE" should be replaced by "DataSource"(no spaces)
and make sure that megas.mdb is properly installed on the odbc connection.
|
|
|
|
|
Hi,
general exceptions (I guess OleDbException qualifies) often contain an "internal exception".
You wont see it if you just look at Exception.Message, but you would see it
when looking at Exception.ToString() so I recommend everyone to always log or display
Exception.ToString(); it is longer by the fact that it provides more information.
I am not sure but expect this to apply to your situation too.
|
|
|
|
|
I am trying to figure out how to retrieve the Event Sources from an event log using WMI. I am using the list to populate a combobox in the main program. I am including the function that I am using to return a comma-separated list of sources that will be put into an array to add to the combo-box ItemRange property. (I realize there may be a better way to do that part, but I am new to this and any constructive criticism will be appreciated.)
When I run the program, the error is that the Strings.Len(arrSourceNames) must be greater than 0. I can't figure out why the "sources()" property from WMI is not populating.
I have used this code on another function to grab the list of Event Logs (application, system, etc) that are available on the computer (with some modifications, of course). It works in that capacity. I think the problem lies somewhere in pulling the array of sources from the WMI query.
Here is the code...
Private Function GetEventSources(ByVal _computerName As String, ByVal _logFile As String) As String<br />
Dim arrSourceNames As String = ""<br />
<br />
If _computerName <> My.Computer.Name.ToString Then<br />
Dim wmiScope As New ManagementScope("\\" & _computerName & "\root\cimv2")<br />
wmiScope.Connect()<br />
<br />
Dim wmiQuery As New ObjectQuery("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName = '" & _logFile & "'")<br />
Dim searcher As New ManagementObjectSearcher(wmiScope, wmiQuery)<br />
Dim queryCollection As ManagementObjectCollection = searcher.Get()<br />
For Each m As ManagementObject In queryCollection<br />
For Each source As String In m("Sources()")<br />
arrSourceNames = arrSourceNames & source & ","<br />
Next<br />
Next<br />
Else<br />
Dim wmiQuery As New ObjectQuery("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName = '" & _logFile & "'")<br />
Dim searcher As New ManagementObjectSearcher(wmiQuery)<br />
Dim queryCollection As ManagementObjectCollection = searcher.Get()<br />
For Each m As ManagementObject In queryCollection<br />
For Each source As String In m("Sources()")<br />
arrSourceNames = arrSourceNames & source & ","<br />
Next<br />
Next<br />
<br />
End If<br />
<br />
Return Strings.Left(arrSourceNames, Strings.Len(arrSourceNames) - 1)<br />
<br />
End Function
Any help to figure this out will be appreciated greatly.
Jonathan Tyler
|
|
|
|
|
jontyler wrote: For Each source As String In m("Sources()")
I'm willing to bet that there is not a property in your returned Win32_NTEventLogFile objects that is called "Sources()". It's probably called "Sources" though.
|
|
|
|
|
Thanks Dave...
You were correct, there is no Sources() property, but there is a Sources property. It was confusing looking at the MSDN content about the Win32_NTEventlogFile class because it shows it as Sources(). Oh well. The other thing I learned, once I fixed that problem, is that I wasn't passing an actual logfile name to the function. I was sending cboList.SelectedValue and should have been sending cboList.Text. Once I made that change, everything worked much better. It also helped me to encapsulate that code into a procedure that I can call in the form load as well as any other time the items changed.
Thanks for your help with this.
Jonathan Tyler
|
|
|
|
|
Hi to all
i am new programmer my proble is i am created one
Service Request report which fetch the data from the
database now when i click on one button i want to convert it into that of the pdf file.
pl. suggest me
Thanks
|
|
|
|
|
If you are using ReportViewer then your user should be able to export to pdf. If you are talking about the ability to generate pdf from your code, then you need 3rd party tools.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
how can i simulate right button click in a VB6 program
plzzzzzzzzzzzzzzzzzzzz help
and plz do tell how can i simulate left button click with its single click and double click properties in VB6
FARAH
|
|
|
|
|
Are you trying to send this mouse click to your own code?? Or to an outside application??
In your own code, you do'nt have to simulate a mouse click. How you reorganize your code to allow calling it from other places depends on what your code is doing in its mouse click event.
If an outside app, look into getting the window handle of the control you want to send the mouse click to and use the Win32 API function SendMessage to send a properly formatted mouse window message to the target window.
|
|
|
|
|
Private Sub Button1_Click(... )
dim f as new form1
f.MdiParent = Me
f.show()
ens sub
this code allways creates a new mdi child i need only one instance at a time. how can i prevent duplicating form1 ?
i am using vs2003
thanks
|
|
|
|
|
Hi,
In the main form:
Private Sub Button1_Click(... )
if bLoaded = True then Exit Sub
dim f as new form1
f.MdiParent = Me
bLoaded = True
f.show()
ens sub
'... in form1.Closed
bLoaded = False
.... in a module
Friend bLoaded as Boolean = False
hope this helps
|
|
|
|
|
thanks 4 ur reply!
is there any other way to load a form other than
"dim f as new form1" this way ?
|
|
|
|