|
Uhhh...you realize this was over 2 years ago, correct??
I gave you everything you need to come up with your own solution. All it took was a tiny bit of effort on your part. No, I'm not coding this for you.
|
|
|
|
|
Hi
Hope someone might help me out, since I'm stuck.
I have to search the registry of several computers to find if there is a
"PendingFileenameOperation" waiting. After some try and error, I've come up
with this solution where I read the registry and add all entries' to an
array, and then add each arrayitem to a string. I then intend to search the
string for a certain path. If the count is above 0 I have a
PendingFileRenameOperation" that requires a reboot.
My problem is as follows:
1) Is this the best way to solve this problem
2) I cant get my regular expression to work.
The code I've come up with is as follows:
Dim objShell
dim strPending, strSessionManager , strAllText
Dim arrFiles ''array containing files that are being renamed
Set objRegEx = CreateObject("VBScript.Regexp")
objRegEx.Global = True
objRegEx.Pattern = "C:\Norman" ''regular expression finding all entries
containing "c:\norman\"
strPending = "PendingFileRenameOperations" ''The regkey we're going to read
strSessionManager="HKLM\System\CurrentControlSet\Control\Session Manager\"
''the registry
Set objShell = CreateObject("WScript.shell")
arrFiles=objShell.Regread(strSessionManager & strPending) 'put all entries
in registry into the array
for each StrFile in arrFiles
strAllText= strAllText & " " & strFile ''add all entries into one long
string with spaces
next
set colMatches = objRegEx.Execute(strAllText)
if colMatches.count > 0 then
''Do something if there are keys in the given directory that is pending a
filerename operation.
end if
Any feedback would be greatly appreciated.
modified on Friday, April 10, 2009 6:29 AM
|
|
|
|
|
Why are you putting all the strings into one massive string?? It's pointless. Just run the RegEx on each string you have in the collection.
I suggest you get Expresso[^]. It's a tool that let's you build and test Regular Expressions against any string data you provide.
But, since you're not really looking for a pattern, but just checking to see if the string starts with "C:\Norman", you can just use the InStr function to check this.
|
|
|
|
|
Hi
thanks for the reply, just a couple of follow up questions, since I'm quite new to VB.
Should I run the regex with a "for each" statement, and nest it with a if statement to check the regex?
Would the InStr function work even though I have to check for 2 or 3 subdirectories as well (C:\norman\nvc, C:\norman\NPM)?
/TheScripter Aka.ScriptSurfer
|
|
|
|
|
TheScripter wrote: Should I run the regex with a "for each" statement, and nest it with a if statement to check the regex?
If I understand what your trying to get it, yes.
TheScripter wrote: Would the InStr function work even though I have to check for 2 or 3 subdirectories as well (C:\norman\nvc, C:\norman\NPM)?
Yes. So long as they all start with the same root directory, "C:\Norman", yes.
|
|
|
|
|
Hi
I'm now trying to get this to work.
for each StrFile in arrFiles ''search array
'intExist = instr(strFile, strSearchString, vbTextCompare)
'if intExist > 0 then
if instr(strFile, "C:\norman", vbTextCompare) > 0 then
counter = counter + 1
end if
next
msgbox(Counter)
But it doesn't work. It seems to fail on the line where the if statement begings.
Please help.
/TheScripter
|
|
|
|
|
You kind-of got it right. The problem is that "C:\Norman" does not equal "c:\norman". So, you force the case to match using:
if inStr(LCase(strFile), "c:\norman", vbTextCompare) = 1 Then
The equals one part is a safety measure. As written here, this will return true if and only if the string starts with any case-variation of "c:\norman".
|
|
|
|
|
In my application there are 3 tab pages
my problem is when i open my application 3rd tab pages should be open and other 1st and 2nd tab page should be disabled.
if i click on enable tab pages then both 1st and 2nd tab page will be enable and 3rd tab page should be disable
i have tried
tabpage.hide property of tab page but it is not work
|
|
|
|
|
|
Thanks for answer its too informatic and good
|
|
|
|
|
A TabControl stores it's pages in a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection_methods.aspx">TabPageCollection</a>[<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpagecollection_methods.aspx" target="_blank" title="New Window">^</a>] . You can add or remove pages from this collection.
Hope this helps
I are troll
|
|
|
|
|
my question is not about how to add or remove tab pages, but i want to enable - disable some tab page by programming
|
|
|
|
|
I'm sorry for wasting your time, but at the time it sounded like a viable alternative to me
I are troll
|
|
|
|
|
Its Ok Dear
As there is no any "Enabled" property of tab page so we have to check it is in tabcontrol's "SelectedIndexChanged" event like the following code
Private Sub tabCon_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tabCon.SelectedIndexChanged
If YourCondition Then
Me.tabCon.SelectedIndex = 1
End If
End Sub
to set defualt TabPage write the following code in form load event
Me.tabCon.SelectedIndex = 1 'Here 1 is the index of desired tabpage
|
|
|
|
|
we are working on the project controlling pc thru mobile ..
we are getting an error in the function parse mail as"invalid procedure call or argument"pls tell us how to rectify tat error...thanx in advance..
the code is as follows...
Private Function ParseMail() As String
On Error GoTo ErrTrap
'
'Parameters
'
'Purpose This procedure will check and let us know what action to be
' taken aginst the command sent from mobile
'
''
'Returns String - Command parsed from the mail
'
'
'Set up our variables
Dim oApp As Outlook.Application 'Create an object for outlook application
Dim oNpc As NameSpace 'Name space to drildown message folder
Dim oMails As MailItem 'To find our mail
Dim sCommand As String
Dim iMsgCount As Integer
Dim sMsgHead As String
'Lets apply values to our variables
Set oApp = CreateObject("Outlook.Application")
Set oNpc = oApp.GetNamespace("MAPI")
iMsgCount = 0
'Lets iterate through an easy For Each loop
For Each oMails In oNpc.GetDefaultFolder(olFolderInbox).Items
If oMails.UnRead Then
sParam = ""
'Change the Subject comparition string based on your service provider message
If UCase(oMails.Subject) = UCase(Trim(txtSubject.Text)) Then
sCommand = Mid(oMails.Body, 1, InStr(1, oMails.Body, Chr(13)) - 1)
If InStr(1, sCommand, "~") <> 0 Then
ParseMail = Mid(sCommand, 1, InStr(1, sCommand, "~") - 1)
sParam = Mid(sCommand, InStr(1, sCommand, "~") + 1)
Else
ParseMail = sCommand
End If
oMails.UnRead = False
End If
' If Send Unread mail Header is checked then send info to mobile
If chkUnReadMail.Value = 1 Then
If UCase(oMails.Subject) <> UCase(Trim(txtSubject.Text)) Then
If InStr(1, sAlertedMails, Trim(oMails.EntryID)) = 0 Then
sAlertedMails = sAlertedMails & Trim(oMails.EntryID) & ","
sMsgHead = "From: " & oMails.SenderName & vbCrLf
sMsgHead = sMsgHead & "Sub: " & oMails.Subject & vbCrLf
sMsgHead = sMsgHead & "DT: " & oMails.SentOn & vbCrLf
sMsgHead = sMsgHead & "MSGID: " & oMails.EntryID & "~"
SendSMS sMsgHead
End If
End If
End If
End If
Next oMails
Exit Function
ErrTrap:
txtLog = txtLog & "Error In ParseMail(): "
txtLog = txtLog & Err.Description & vbCrLf
End Function
waiting for your earliest reply..
pls help us with tat error..
|
|
|
|
|
You haven't said on which line the problem occurs. But, from the error message, you probably sent an incorrect argument to a method call somewhere. Without knowing on which line the error occured, it's pretty much impossible to tell you what went wrong.
|
|
|
|
|
Hi all
Can some one plz tel me what is the difference between textbox.text = "" and textbox.clear.
The same thing works for some some other controls also. ????
|
|
|
|
|
Basically both do the same task
We can blank a textbox control by assinging a blank string ie "" or by calling its Clear method
|
|
|
|
|
To make it worse, there's also
Textbox.Text = String.Empty Since it is a reference-type, you could even say
Textbox.Text = Nothing In programming there's seldom a single way or approach to do something
I are troll
|
|
|
|
|
Hi.
I need to read the news feed for example (http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/uk/rss.xml) and store the news part alone in a text file . I can get the content and store in a html file with TortugaActiveX. I need to do in vb 2008. I can use the text data for msagent. Please any one can help me..?
Thanks
Surej
|
|
|
|
|
So what part of this are you having problems with?? Downloading the file?? Parsing the XML?? Saving the data?? ......??
|
|
|
|
|
I can download the file ..I need parsing the XML file so i can get only the news part and save as a text file ..That i can use for msagent. I tried activex from chilkat too..i could not get the desired result
Thanks
Surej
|
|
|
|
|
Any easy way to do this..?
|
|
|
|
|
I'm trying to upload a file in VB.NET using an HtmlInputFile, but everytime I upload, the HtmlInputFile's PostedFile is Nothing.
Here is my ASP.NET code:
<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
<asp:DataGrid id="dgTitles" runat="server" OnUpdateCommand="dgUpdate" DataKeyField="ID">
<Columns>
<asp:TemplateColumn HeaderText="Title" >
<ItemTemplate>
<asp:Label ID="lTitle" Runat="server">
<%# DataBinder.Eval(Container, "DataItem.Title" )%>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tTitle" Runat="server" text='<%# DataBinder.Eval(Container, "DataItem.Title" )%>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Image">
<EditItemTemplate>
<input id='fuEditImage' type="file" name="fuEditImage" runat="server" enctype="multipart/form-data" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:EditCommandColumn UpdateText="Update">
</asp:EditCommandColumn>
</Columns>
</asp:DataGrid>
</form>
Here is my VB.NET code:
Sub dgUpdate(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Try
Dim Title = CType(e.Item.FindControl("tTitle"), TextBox).Text
Dim fuUpload As System.Web.UI.HtmlControls.HtmlInputFile = CType(e.Item.FindControl("fuEditImage"), _
System.Web.UI.HtmlControls.HtmlInputFile)
If Not fuUpload.PostedFile Is Nothing Then 'This always = false
If Not fuUpload.PostedFile.FileName = "" Then
UploadImage(fuUpload)
End If
End If
Catch ex As Exception
'Handle Exception here
End Try
End Sub
When I upload a file, fuUpload is not Nothing, but fuUpload.PostedFile is.
The inputted "Title" text is recognized no problem.
I've also tried with FileUpload object and tag, instead of input tag and HtmlInputFile-- same result.
Can anyone tell me what I'm doing wrong? Why is PostedFile always nothing?
Thanks!
|
|
|
|
|
This question should really be asked in the ASP.NET Fourm. It has nothing to do with VB.NET at all.
|
|
|
|