|
Hi all. I've seen how to do a file system watch on a local folder. Is it possible to watch a remote folder on an ftp site?
Code for local folder:
gfswWatchFolder = New System.IO.FileSystemWatcher()
gfswWatchFolder.Path = "C:\My Documents\Temp2"
gfswWatchFolder.NotifyFilter = IO.NotifyFilters.DirectoryName
gfswWatchFolder.NotifyFilter = gfswWatchFolder.NotifyFilter Or IO.NotifyFilters.FileName
gfswWatchFolder.NotifyFilter = gfswWatchFolder.NotifyFilter Or IO.NotifyFilters.Attributes
AddHandler gfswWatchFolder.Changed, AddressOf LogChange
AddHandler gfswWatchFolder.Created, AddressOf LogChange
AddHandler gfswWatchFolder.Deleted, AddressOf LogChange
AddHandler gfswWatchFolder.Renamed, AddressOf LogChange
gfswWatchFolder.EnableRaisingEvents = True
and
<pre> Private Sub LogChange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Changed Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been modified." & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Created Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been created." & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been deleted." & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Renamed Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been renamed." & vbCrLf
End If
End Sub
I know how to open a remote folder using
<pre>Dim request As FtpWebRequest = DirectCast(WebRequest.Create(mstrFTPUri & strRemoteApplicationFolder), FtpWebRequest)
etc. etc. but how do I combine the two? Thanks in advance.
|
|
|
|
|
FileSystemWatcher only works for folders on your local PC, and folders on other computers on your LAN which you can access using a UNC path. It does not support monitoring an FTP folder.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
To delete the Category I use Code :
Private Sub DeleteCategories()
Dim objNS As NameSpace
Dim objCat As Category
Set objNS = Application.GetNamespace("MAPI")
If objNS.Categories.Count > 0 Then
For Each objCat In objNS.Categories
objNS.Categories.Remove (objCat.CategoryID)
Next
End If
Set objCat = Nothing
Set objNS = Nothing
End Sub
=========
Then to Restore Categories I use:
Sub RestoreCategories()
AddCategory "1", 4, 0
AddCategory "2", 18, 0
AddCategory "3", 22, 0
AddCategory "4", 14, 0
AddCategory "5", 5, 0
AddCategory "6", 7, 0
AddCategory "7", 6, 0
AddCategory "8", 9, 0
AddCategory "9", 8, 0
AddCategory "10", 10, 0
AddCategory "11", 2, 0
End Sub
Where the issue is it works in personal Account but not in Shared mailboxes ? Any Ideas.
|
|
|
|
|
By using objNs from GetNameSpace you are using the default account. You have to get hold of the Store for (each) shared mailbox Account and manipulate that instead.
Sorry I don't have a specific working example but the following link might help point you in the right direction. If nothing else you now know what the problem is to help your research
Working with VBA and non-default Outlook Folders[^]
|
|
|
|
|
I am calling Form_BeforeUpdate directly from a Close (Form) button's onClick Event, to handle various circumstances when the form is only partially filled in but the User wants to bail out. Under certain (perfectly feasible) circumstances, Form_BeforeUpdate is correctly setting Cancel to True within itself, but it is not being passed back to the calling Sub! Subroutine parameters are ByRef by default, but setting Cancel explicitly to ByRef in the definition of Form_BeforeUpdate does not change the misbehavior. Here are the two Subs:
Private Sub cmdClose_Click()
Dim Cancel As Integer
Form_BeforeUpdate (Cancel)
If Cancel Then
If MsgBox("This record contains errors. Do you wish to correct them before closing the form?", vbYesNo, "Errors") = vbYes Then
Exit Sub
Else
If Me.NewRecord Then
MsgBox "The current record will be discarded.", vbInformation
Else
MsgBox "Any changes made to the current record will be discarded.", vbInformation
End If
Me.Undo
End If
End If
blMayClose = True
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rst As New ADODB.Recordset
If Me.NewRecord Then Contact_Pt = lbxContacts.Value
Set rst = New ADODB.Recordset
rst.Open "SELECT ID FROM Assets WHERE package_Pt = " & ID, CurrentProject.Connection, adOpenStatic, adLockReadOnly
If Not (rst.EOF And rst.BOF) Then
If IsNull(Start_Date.Value) Or IsNull(End_Date.Value) Then 'this is where Cancel gets set to True
MsgBox "You must enter start and end dates for the package before saving it.", vbExclamation, "Dates Missing"
Cancel = True
ElseIf End_Date.Value <= Start_Date.Value Then
MsgBox "The end date must be after the start date.", vbExclamation, "Invalid dates"
Cancel = True
End If
End If
rst.Close
Set rst = Nothing
End Sub
|
|
|
|
|
The way you are calling the sub is strange
Form_BeforeUpdate (Cancel) That should be either
Call Form_BeforeUpdate(Cancel) or
Form_BeforeUpdate Cancel I can't remember what surrounding a variable in parentheses does, other than make that code not work obviously .
I'll have a dig around, but in the meantime either insert "Call" or drop the ()
|
|
|
|
|
Found it!
Using the parentheses is forcing VBA to evaluate the bracketed expression (in this case, your variable Cancel ) and then pass it as ByVal into the subroutine. Ergo the value remains unchanged in the calling sub.
See Matthieu Guindon's solution here [^] for a fuller explanation
|
|
|
|
|
Thanks! I had given up and used a workaround (which actually turned out to have other advantages, so it wasn't all bad). VBA's requirement that you not surround sub/function arguments with parens (unless you make an explicit Call) is always catching me out, since every other language I use require the parens. Fortunately, it mostly affects implicit calls with multiple arguments, where putting in the parens provokes an immediate syntax error in the editor. This case is a particular pain since the bad syntax is not flagged but nevertheless changes the meaning of the call.
|
|
|
|
|
VBScript and VBA require parenthesis around the parameters of functions that return a value.
For functions that don't returns a value, no parenthesis go around the parameter list.
It's the stupidest thing I've ever seen.
On, and you never need to use "Call" to call another function at all.
|
|
|
|
|
1: It's the stupidest thing I've ever seen. I couldn't agree with you more!
2: and you never need to use "Call" to call another function at all. Except when you put parentheses around your parameter list. In which case quote 1 applies
|
|
|
|
|
In the mountain of VB6, VBA, and VBScript code I've written, I've never used 'Call'. It just seemed so COBOL to me, YUK!
|
|
|
|
|
|
I want to Use the following Com Funktion ( From idl File)
[id(2)] HRESULT Request ( [in] long id, [in] BSTR version, [in,out] BSTR sender, [in] BSTR login, [in] BSTR selection, [in, out] BSTR* data , [out, retval] long* retval );
from my Visual Basic Scriot ( Visual Studion 2015) wenn i call my funktion from ma scrip like tis
Private Sub Request_1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Request_1.Click
Dim r As Integer
Dim data As String
Dim ID As String
Dim sender As String
sender = "DatO"
If ID_KS_1.Text <> "" Then
ID = "ID_KS=" & ID_KS_1.Text & ","
sender = "KS_Trifact"
End If
ErrorText.Text = ""
If obj Is Nothing Then obj = CreateObject("NmsTaskDbSv.64Bit_NmsDbData")
'UPGRADE_WARNING: Couldn't resolve default property of object obj.Request. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'r = obj.Request(15101, "1.0", sender, "customerservice/customer", ID & "ACCOUNT=" & Par_1_1.Text, "test")
r = obj.Request(15101, "1.0", sender, "customerservice/customer", ID & "ACCOUNT=" & Par_1_1.Text, (data))
If (r = 0) Then
Result_1.Text = data
Else
ShowLastError()
End If
End Sub
it seams to work but rhe response dues not arrive in the data variablele wenn i make the call j = CreateObject without () lik this
'r = obj.Request(15101, "1.0", sender, "customerservice/customer", ID & "ACCOUNT=" & Par_1_1.Text, data)
i get a type mismatch error ho i have to call Request to get the Data String as answer
Thanks
|
|
|
|
|
You keep saying "VB Script" when the code you posted is NOT VBScript. It's VB.NET. VBScript is a very different language and runtime environment from VB.NET.
If you added a reference to the COM .DLL you're using, you would not have to use CreateObject to create an instance of the class. You could just "new one up".
Dim obj As New 64Bit_NmsDbData
Of course, you'd have to import the namespace for that class at the top of the code.
|
|
|
|
|
Hi everyone, my name is Maurizio and my question is this
In VB I would like to know how to create one or more objects of the same type at run time.
I'll explain:
1) In a form I insert a textbox1 and a button
The purpose of my request is to know how: By pressing this button
It should bring up another textbox and so on.
that's all !!!!
If I remember correctly I used the New function
But it seems that this does not work in vb.
Could you please help me Thanks
Greetings from Maurizio
|
|
|
|
|
The New keyword does work. All it does is create an instance of a type, be it a class or a COM type, or the like.
You create a new TextBox just by "newing one up":
Dim myNewTextBox As New TextBox
You then have to set it's properties, like Top, Left, Height, Width to set the size and position on the Form or in another container.
Then you have to add it to the Controls collection of the container you're adding it to, like your Form:
myForm.Controls.Add(myNewTextBox)
|
|
|
|
|
You can do it like suggested by Dave - the other way could be (perhaps easier to code and to maintain for you) :
- Create the Textbox you want to bring up from the beginning with the Designer.
- Set it's Visible-State to False
- When pressing the Button set it's Visible-State to True.
In this case you are able to make all the relevant connections.
You don't need to modify the Controls-Collection from the Form, catch the Events from the new Control and so on ...
|
|
|
|
|
Thank you to everyone for your interest
But it wasn't the answer I would have expected from experienced people like you.
Thanks anyway
/p.s) But if instead of cloning I asked for a sort of (Textbox) Dynamic with at least 5 possibility of creating (Textbox) on request!
What would have changed?
I'll explain :
If I press the key inserted in the form and I create the first dynamic (Textbox)
How can I go about creating a new one at least five times the same size as the first?
I tried to write something like this; But it is valid only for the first dynamic (Textbox)
Therefore I would miss being able to create all the others every time I press the create button.
Thank you
|
|
|
|
|
|
I just told you how to do it. It is the correct answer based on your own description of what you want to do.
|
|
|
|
|
Perhaps (to make it much easier for us) you should provide your Code-Snipped ...
Sometimes a "Picture" tells more than 1000 words ...
|
|
|
|
|
They all "default" to the same size and location unless you "change" the property's default value at "construction" time or subsequently. Based on your problem description, that's all that "experience" dictates. If your requirements are more complex, you have failed to articulate them; perhaps it needs "reflection"; but that requires "experience".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi
I have created a program that is intended to be used by multiple users (each on their own computer) who access the same SQL database. I have also created a separate updater program to sit alongside the main application. However, I am unsure how to check if there are any users in the main program before the update is run. (This is easy to do on a single user application but not sure on multi-user).
Any help is greatly appreciated
(I am relatively green here so please be kind)
|
|
|
|
|
If you want to update only client application, the number of users connected to the database is not important.
Does updater have to update database too?
|
|
|
|
|
No. The client will be updating the database. It is more an issue of ensuring no users are in the program while the update is running.
If this was a single user prograM then it is easy to check and force a close. I am not sure when there is more than one user (from different computers)
|
|
|
|
|