|
That's not a string collection, it's a Dictionary/HashTable.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I'm not a developper, but an Oracle DBA. I'm new to scripting in windows (better on unix). I tried to create a script to get configuration values that Oracle store in an XML file and use them. I encounter an error, which seems to be a object/variable type casting error :
C:\WinScripts\Myscript\switch_all_logs.vbs(73, 3) Erreur d'exécution Microsoft VBScript: Objet requis: '[string: "C:\oracle\ora92"]'
My code :
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
'Title : switch_all_logs.vbs<br />
'Description : Switch All Oracle RDBMS logfiles<br />
'Author : G.Reboute<br />
'Company : <br />
'Created : 29/01/2007<br />
'Rel. : 1.0<br />
'Rel. Date : 29/01/2007<br />
'Purpose : to rename <namefile.log> into <namefile.log.YYYYMMDD><br />
'Note : produces a log of the executed actions in the execution <br />
' directory named "switch.log" and an Application Log entry also<br />
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
Option Explicit<br />
'Variables<br />
Dim WSHShell, objArgs, XMLread, XMLreader<br />
Dim strOracleRegKey, strInvLoc, strOracleHome, retcode, strDir<br />
Dim xmlDoc, xmlHomeList, xmlRoot, xmlNode, myErr, i<br />
Dim oFileSys, xmlAttrib, toto<br />
<br />
' On est oblige de ne pas tenir compte des erreurs au debut du script<br />
' car la methode RegRead ne renvoit pas de code erreur "attrapable"<br />
Err.Clear<br />
On Error Resume Next<br />
Set WSHShell = WScript.CreateObject("WScript.Shell")<br />
Set objArgs = WScript.Arguments<br />
Set oFileSys = CreateObject("Scripting.FileSystemObject") <br />
strDir = oFileSys.GetAbsolutePathName(".\")<br />
<br />
' Lecture du repertoire d'inventory Oracle<br />
strOracleRegKey = "HKLM\software\oracle\inst_loc"<br />
strInvLoc = WSHShell.RegRead(strOracleRegKey)<br />
If Err.number <> 0 then<br />
WScript.Echo("L'erreur de lecture de la cle = " & Err.number)<br />
' Si ce n'est pas defini on essaye a l'emplacement par défaut<br />
strInvLoc = "C:\Program Files\Oracle\Inventory"<br />
End if<br />
' On remet en route la gestion des erreurs<br />
On Error goto 0<br />
<br />
'Creation du Document Xml<br />
Set xmlDoc = CreateObject("Microsoft.XMLDOM") <br />
'WScript.Echo("Le fichier = " & strInvLoc & "\ContentsXML\inventory.xml")<br />
<br />
' Chargement du XML et gestion des erreurs<br />
xmlDoc.Load(strInvLoc & "\ContentsXML\inventory.xml")<br />
If xmlDoc.parseError.errorCode <> 0 Then<br />
myErr = Err.Description & vbCrLf<br />
myErr = myErr & xmlDoc.parseError.reason & " ligne: " & _ <br />
xmlDoc.parseError.Line & " col: " & _<br />
xmlDoc.parseError.linepos & _<br />
" texte: " & xmlDoc.parseError.srcText<br />
MsgBox myErr, vbCritical, "Une erreur est apparue durant le chargement"<br />
WScript.Quit 1<br />
End If<br />
<br />
' xmlRoot est l'image du document en "pur" XML<br />
Set xmlRoot = xmlDoc.DocumentElement<br />
'WScript.Echo(root.xml)<br />
<br />
' On se positionne sur le bon noeud<br />
Set xmlHomeList = xmlRoot.SelectNodes("HOME_LIST/HOME")<br />
If xmlHomeList.length <=0 then<br />
WScript.Echo("Je n'ai rien pu trouver pour HOME_LIST/HOME")<br />
WScript.Echo("Etes vous bien sur qu'il s'agisse d'un fichier d'inventaire Oracle ?")<br />
WScript.Quit 2<br />
End if<br />
'WScript.Echo("On passe a la recherche proprement dite" & VBCRLF & VBCRLF & VBCRLF )<br />
i = 0<br />
For Each xmlNode In xmlHomeList<br />
' WScript.Echo(xmlNode.nodeName)<br />
Set xmlAttrib = xmlNode.Attributes.getNamedItem("LOC")<br />
' The error appears on the next line<br />
Set strOracleHome = xmlAttrib.Value<br />
Wscript.Echo "Oracle Home " & i & " = " & strOracleHome<br />
Wscript.Echo "Current Dir = " & strDir<br />
Wscript.Echo "Commande = " & strDir & "\switchlistenerlog.vbs " & chr(34) & xmlAttrib & chr(34)<br />
' retcode = WSHShell.Run(strDir & "\switchlistenerlog.vbs " & chr(34) & xmlAttrib & chr(34), 1)<br />
If retcode <> 0 Then<br />
WScript.Echo("script de switch des logs du listener introuvable")<br />
WScript.Quit 3<br />
End If<br />
Set strOracleHome = Nothing<br />
Set xmlAttrib = Nothing<br />
i = i + 1<br />
Next<br />
The XML file (I had to add the spaces to show it on the board):
<br />
< ?xml version="1.0" standalone="yes" ?><br />
< !-- Copyright (c) 2005 Oracle Corporation. All rights Reserved --><br />
< !-- Do not modify the contents of this file by hand. --><br />
< INVENTORY><br />
< VERSION_INFO><br />
< SAVED_WITH>10.2.0.1.0</SAVED_WITH><br />
< MINIMUM_VER>2.1.0.6.0</MINIMUM_VER><br />
< /VERSION_INFO><br />
< HOME_LIST><br />
< HOME NAME="OraHome92" LOC="C:\oracle\ora92" TYPE="O" IDX="1"/><br />
< HOME NAME="OraHomeClient10g" LOC="C:\oracle\10.2.0\client" TYPE="O" IDX="2"/><br />
< /HOME_LIST><br />
< /INVENTORY><br />
When I make an echo of xmlNode.Attributes.getNamedItem("LOC"), it's OK, I get the value of the attribute, but when I want to use it as a string, I got the error.
|
|
|
|
|
I'm working on a program where I need to read the file names in a directory into an array. The code I have written reads the file names with the full directory information. What I want to do is read the file name only. My current code which reads the file and directory information is as follows:
For Each foundfile As String In System.IO.Directory.GetFiles("e:\stocktestdata")
'lstDisplay.Items.Add(foundfile)
'stocksymbolarray(counter) = foundfile
'counter = counter + 1
'Next
The code I have written to read only the file name is as follows, but it does not work.
'For Each foundfile As String In System.IO.Directory.GetDirectories("e:\stocktestdata\")
' lstDisplay.Items.Add(foundfile)
'stocksymbolarray(counter) = foundfile
'counter = counter + 1
' Next
Can someone help me out? Thanks.
George
|
|
|
|
|
GetDirectories and GetFiles do exactly what they are named to do. Using GetDirectories as you may have discovered returnes the directories found under a given path. You can parse the files found and get just the file name by using IO.Path.GetFilename().
|
|
|
|
|
Thanks for the help. I got things working properly last night.
George
|
|
|
|
|
How To Creat MSG Box Whitch will be automaticly close after 2 to 3 sec.
s
|
|
|
|
|
Create your own form that looks like a message box.
---
Year happy = new Year(2007);
|
|
|
|
|
Hello,
U can use Senkeys function with timer control.
Regards,
Nilesh
|
|
|
|
|
Hi everybody,
I'm trying for a while (and my head is starting to become nuts) to do some animation on my PocketPC application (VB.NET with CompactFramework 2 under Windows Mobile 5), but I can't do what I would like.
I have some beautiful pictures I would like to load one after another, and in the same time I have some stuffs to do (like initializing a TCP Interface).
The problem is that I can't get an event that launch these 2 processes when the form is completely loaded.
I tried:
- Me.Load , but it occurs just before the form is displayed;
- Me.Activated , but the problem is that in my init process I have a form2.Show ; form2.Hide to allow the form2 to load background (this form2 is quite big);
- Me.Validated , but it seems to never happen.
Could you please give me a tip ?
Thanks a lot,
Ch'Portos.
-- modified at 10:03 Monday 29th January, 2007
Yop Yop !!
|
|
|
|
|
Can anyone give me the source code for vb 6 to delete the files from the temporary internet files folder in win xp, I`ve got lots of source code from various vb sites but none of it works, I just need a small proggy to delete my temp int files and cookies, I can delete the cookies but not the others.
Internet explorer and Firefox do not delete all the files which is why I need a proggy, the smaller the better sos I can understand it and use it in future programs
Thanx in advance
wullie
|
|
|
|
|
|
Im trying to get a global integer value from my vb program, into a certain point in a word document (for a certificate), anyone got any ideas.
Word will be 2003, vb.net 2005
|
|
|
|
|
|
The global part is easy, you can see it anywhere. Are you already interacting with Word ? Is this VB6 ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi, thanks for the reply.
It is just a simple program made within vb.net 2005.
All i am trying to do is get the global integer value already created via the users input, then when i click a button, input it in a word document, and print the word document...
Its gonna be for printing a name on a sheet!
Any help welcome
|
|
|
|
|
OK, you can download an MS SDK For controlling word from .NET, I think that's what you need. You will need Word on ay machine it runs on of course.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
Hi,
I have defined context menu. I need to make visible some menu items depending on which control in the form it shows(righ click).
How do i get the name of control, from where the context menu is displayed?
Any luck.
Be simple and Be sample.
|
|
|
|
|
what do u want to say i don't know. But as i know you want use same code whish u have written. as u write code on any click event and use same again. if u want so you can this.
oldbutton_Click(newbutton,e)
here oldbutton_Click is old button name "Which Code u want to call" & newbutton is new button name
& e is the event.
Thanks & Regards
Form :-
Vikash Yadav
|
|
|
|
|
Well unless your controls share events you can just modify the context menu in the mousedown event for your control. You know which control it is because it's the only one that fires it's own mousedown event.
If your controls are sharing events then you could check to see wich control it was by testing the sender object. You can see if the sender object is a certain control by doing this.
If sender is textbox1 then
'Modify context menu here
End If
If on the other hand you want all your textbox's to have a given menu you could do this.
If sender.gettype is gettype(textbox) then
'Modify context menu here
End If
and lastly if you really need to find out the name you could cast the sender object as a control and check it's name property.
dim ctrl as control = trycast(sender,control)
If ctrl isnot nothing andalso ctrl.name = "textbox1" then
'Modify context menu here
end if
|
|
|
|
|
In my first post I hadn't considered you were trying to figure out what control opened the context menu in the context menu's opening event. The sourcecontrol property gives you the control that opened it. This code shows some examples:
Private Sub ContextMenuStrip1_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
Dim source As Control = ContextMenuStrip1.SourceControl
'Example: Test it's name
If source.Name = "Textbox1" Then
End If
'Example: Test if it's a specific control
If source Is TextBox1 Then
End If
'Example: Test if it's a type of control
If source.GetType Is GetType(TextBox) Then
End If
End Sub
|
|
|
|
|
Thanks,
this is what exactly I needed.
Rams.
Be simple and Be sample.
|
|
|
|
|
Hey Everybody!
Well i need to display something like this on form:
15 + 10 = 10 + 5 + 10
now i tried gdi+ but i can't find a way to find out where like the 15 ended to start the + in another color so i thought the rich texy box would be easy'er but it seems it's been to long since i used it as well:
the code:
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim varStart As Integer = 0<br />
<br />
rtBox.Text = "Hallo"<br />
rtBox.Select(varStart, Len(rtBox.Text))<br />
rtBox.SelectionColor = Color.Red<br />
rtBox.Refresh()<br />
<br />
MsgBox("Check 1")<br />
<br />
varStart = Len(rtBox.Text)<br />
<br />
rtBox.Text = rtBox.Text & " My Name Is "<br />
rtBox.Select(varStart, Len(rtBox.Text) - 1)<br />
rtBox.SelectionColor = Color.Black<br />
rtBox.Refresh()<br />
<br />
MsgBox("Check 2")<br />
<br />
varStart = Len(rtBox.Text)<br />
<br />
rtBox.Text = rtBox.Text & "BadBoyTazz"<br />
rtBox.Select(varStart, Len(rtBox.Text))<br />
rtBox.SelectionColor = Color.Red<br />
rtBox.Refresh()<br />
End Sub<br />
now the reason for the msgbox is just to force the pause of the code so that i can see how the rich text box refreshes! It does the same with or with out it!
What happens here is it writes the "Hallo" in red, then the " My Name " in Black & then it writes everything in RED after i add "BadBoyTazz"! What am i missing to get it to look like this: Hallo My Name Is BadBoyTazz
I can't see what the difference is between the first 2 words & when i add the "BadBoyTazz"
Thanx...
PS: If anybody can point me to a place where i can find the selution to the rich text box or gdi "version" please
-- modified at 6:52 Monday 29th January, 2007
I Live In My Own Little World! But It's Ok, They Know Me Here!
|
|
|
|
|
A while back I wrote some software to colour code a report that was displayed in an RTF box. Perhaps it will be of some use to you:
Private Sub Add_text_to_report(ByVal The_text As String, ByVal Style As System.Drawing.FontStyle, ByVal Colour As System.Drawing.Color)
Dim Font As New Font(rtBox.Font.FontFamily, rtBox.Font.Size, Style)
Dim Len As Integer = rtBox.Text.Length()
' Add the text
rtBox.AppendText(The_text)
' Now format it as specified
rtBox.SelectionStart = Len
rtBox.SelectionLength = The_text.Length
rtBox.SelectionFont = Font
rtBox.SelectionColor = Colour
' Clear the selection
rtBox.SelectionStart = 0
End Sub
Simply add this sub-routine into your form and whenever you want to add text to the RTF Box just call the routine, specifying the string to add, its format (i.e. bold, underline etc, and its colour)
Hope this helps,
Regards
Martin
|
|
|
|
|
Thanx will give it a try!
I see now what i missed "AppendText" just can't figure out why the example i've got works with out append but myne doesn't!
Thanx again!
I Live In My Own Little World! But It's Ok, They Know Me Here!
|
|
|
|