|
Is it something like this
dim x as an integer
x = Process.start("program.exe")
call Waitforexit(x)
Please reply asap.
|
|
|
|
|
No, something like this:
Dim p As Process = Process.Start(...)
p.WaitForExit()
You can also pass an additional parameter to WaitForExit which specifies a timeout period - useful if your application is waiting for a process to finish, but cannot finish for some reason
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks.
Now i have another problem.sorry.
I have delete a file in a directory
but only if the file exists
i am trying to use mycomputer.getfiles.method but don't no how to do it.
Please reply.
|
|
|
|
|
If(File.Exists("FilePath"))<br />
File.Delete("FilePath")<br />
End If
You may want to look into the System.IO namespace - in particular the File, Path, Directory, DriveInfo, FileInfo and DirectoryInfo classes
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
it says file isn't declared.
Help!
|
|
|
|
|
You may want to make a new topic for completely unrelated topics. And chances are that you need to add an Imports System.IO at the top of your code file
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
ya i got it now
All problems solved.
Thanks so much to every one for helping me.
|
|
|
|
|
i have got a source code file (classlibrar style), which has successfully been impiled to a DLL file.
so how can i load this dll file in my .net vb project? i want details ,thank you!
|
|
|
|
|
1. Add the file to your project:
In the solution explorer,
right Click on your project,
select add --> existing item.
Find the dll file and add it.
2. Add a reference to the dll
in the solution explorer,
double click on My Project,
select the references tab.
click add.
select the browse tab
Find the dll file and click ok
|
|
|
|
|
Thank you,i got it.but how can i declare function to use a function in DLL ?
|
|
|
|
|
Once the dll has been referenced, you need to create an instance of it and then you can call any exposed methods or functions it conatins. For example, if your DLL is named MyLibrary and has a function called MyFunction that takes two string parameters. This is how you would call it and use it:
Dim objLib as New MyLibrary<br />
Dim str as String<br />
str = objLib.MyFunction("Hello", "World")
|
|
|
|
|
Hi guys,
I'm working in VBexpress2008 using the sql server compact that comes with it. I'm trying to delete a row from a listbox out of a table using this code:
Private Sub Deleteip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Deleteip.Click
DataSet.IP.Rows(IPlistbox.SelectedIndex).Delete()
DataSet.IP.AcceptChanges()
IPTableAdapter.Update(DataSet.IP)
End Sub
it all seems to work fine, deleteing it from the dataset, no errors when running the tableadapter.update but when i go back into it they are there again!
any suggestions would be appreciated, thanks
Chris
|
|
|
|
|
A possible answer might be that when you re-run the code it is copying the database from the original into the bin\debug folder.
This happens when you run in debug so that the testing does not trash the original database.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Does your table adapter have a delete statement defined within the dataset?
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
The problem is that you called AcceptChanges before you called Update. This tells the DataSet that the modifications that it is holding should now be considered synced up with the database. now that you've essentially wiped out all the changes, when you call Upgdate, the DataAdpater doesn't see any changes to make to the backing database, so nothing changes. When you go run your code again, you see the database exactly how it was when you ran it the last time.
|
|
|
|
|
doh! Yuppers!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Wow thanks for the reponse. I think I was going wrong as I was under the impresion that when you mark the row for deletion the acceptchanges removes it from the dataset then the update syncsthe source with the dataset. now I know! and yes, the tableadapter doesn't have a valid delete command.
thanks alot!
chris
|
|
|
|
|
Tha'ts why we have documentation on nearly every class, method and property in the .NET Framework. Just looking at a method name and trying to guess at what it does isn't doing you any favors.
|
|
|
|
|
very true, but that was the impression I got from the documentation! Oh well, still very new to this. Here's how I fixed it for peoples reference:
Private Sub Deleteip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Deleteip.Click
Dim item, port As Integer
Dim ip As String
item = IPlistbox.SelectedIndex
ip = DataSet.IP.Item(item).IPaddress
port = DataSet.IP.Item(item).Port
DataSet.IP.Rows(IPlistbox.SelectedIndex).Delete()
DataSet.IP.AcceptChanges()
IPTableAdapter.DeleteQuery(ip, port)
End Sub
|
|
|
|
|
Hi,
In am doing the simultaneouly two imports. Which export the data from excel to sql server.
There are some common tables, which are being approached by both these imports. and results in deadlock
Transaction (Process ID 53) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
In the sql profiler, i have seen that a couple of queries are taking time, which are using common tables in imports. I have optimized it also.
Can you provide me any suggestion?
Thanks
|
|
|
|
|
Um...Don't do the imports simultaneously?
Do some kind of check to make sure the files not being used by another process before doing the import.
|
|
|
|
|
This would tell me that you can't do the imports simultaneously since they both add/modify to the same table(s).
You don't have a choice but to do them sequentially.
|
|
|
|
|
Hi there,
This would be my first post that is basically asking/requesting points of view from various Bloggers/experts from this site whom I welcome to comment on coding principles rather than talking about code specific.
Some background information to introduce this subject, basically I am working on a project that simplifies automating a summary form in MS Word that involves in several processes along the way. It has text forms fields and few check boxes that is associated to several bookmarks.
I can use VBA code to collect information from these bookmarks and make control structure decisions given input from users. I have a drop down lists that I will have to use MS Access instead of an array code to fill them up as I was shocked to find VBA telling me that 25 continuation lines is the maximum when I wanted to fill an array for over 120 items. bummer!
Anyway, I know about object oriented programming and have seen the benefits, especially from books on Word / Excel VBA suggesting a Class Module using examples of employees with time sheet objects.
Trouble is, I couldn't confidently use it but I wanted to so I can organise the forms like objects and put the results into a collection like Word / Excel organises data. I tend to be cautious as I used to write code like I would write COBOL structured programming (I used to do this mind you!)
I would use those examples provided from books to develop my own patch of code that achieves a sort of re-factoring about approximately 40 lines of VBA module code when the user clicks the button that starts the module.
Let's give a fictional example that give you an idea or essence of my module project at work to show you what I mean and I wanted to re-factor these ideas from this CommandButton1 module into a Class Module that simplifies duplicate code.
Please forgive me for lacking any comments in the code.
Here are my questions - What's the best approach in converting this into a VBA class module?
What guidelines would people offer from their experience into turning modules into class modules?
This code works when a button on the form is pressed after entering information into three fields in Word.
<br />
Sub CommandButton1_Click()<br />
Dim objA as Document<br />
Dim strB as String<br />
Dim strC as String<br />
Dim strD as String<br />
Dim blnB as Boolan<br />
Dim blnC as Boolan<br />
Dim blnD as Boolan<br />
<br />
Set objA = ActiveDocument<br />
<br />
blnB = false<br />
blnC = false<br />
blnD = false<br />
<br />
strB = objA.FormField("FieldA").Result<br />
<br />
if strB = "Somebody" then<br />
blnB = True<br />
<br />
strC = objA.FormField("FieldB").Result<br />
<br />
if strC = "Anybody" then<br />
blnC = True<br />
<br />
strD = objA.FormField("FieldC").Result<br />
<br />
if StrD = "Otherbody" then<br />
blnD = True<br />
<br />
If blnB then<br />
if blnC then<br />
if blnD then<br />
Save this file<br />
else<br />
Msgbox "Error entering Field C"<br />
end if<br />
else <br />
msgbox "Error enter Field B"<br />
end if<br />
else<br />
msgbox "Error enter Field A"<br />
end if<br />
<br />
End Sub<br />
Regards, Psionic
|
|
|
|
|
<pre>
Hello ...
Problem :
problem regarding sending mail through CDO using Excel macro
For some attempts i sucussful sent mails with attachment but suddenly it droped. I dont know what was the problem but I think none of the errors were observed during the process.
More over I am not able to find mail in my inbox to which i had configured in the macro.
My system configuration is - Win XP Sp3 o/s &amp; working on Office 2003
Excel VBA Code is as follows....
Option Explicit
Private Sub CommandButton1_Click()
Dim objMsg As Object
Dim objConf As Object
Dim objFlds As Object
Dim strBody As String
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay
Set objMsg = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")
objConf.Load -1
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587 '465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mailserver4macro@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "jose309930"
.Update
End With
strBody = "This is a sample message." & vbCrLf
strBody = strBody & "It was sent using CDO." & vbCrLf
With objMsg
Set .Configuration = objConf
.To = "hai_jimson_jose@yahoo.com"
.From = "mailserver4macro@gmail.com"
.Subject = "Hai jimson!! This is a CDO test message"
.TextBody = strBody
'use .HTMLBody to send HTML email.
'.Addattachment "c:\temp\Scripty.zip"
.Fields("urn:schemas:mailheader:disposition-notification-to") = "mailserver4macro@gmail.com"
.Fields("urn:schemas:mailheader:return-receipt-to") = "mailserver4macro@gmail.com"
.DSNOptions = cdoDSNSuccessFailOrDelay
'.Fields.Update
.Send
End With
End Sub
</pre>
|
|
|
|
|