PRINCIPALE > LISTA DELLE AREE DI DISCUSSIONE > VISUAL BASIC: DOMANDE GENERALI > MESSAGGIO

Eseguire una ricerca veloce nell' archivio delle risorse di Visual Basic Italia®: 

Preso dall'archivio...

Premere il pulsante sotto per accedere direttamente ad un articolo o ad un esempio preso in modo casuale dall'archivio.

Ultimo e-book pubblicato:

"INTRODUZIONE AI CSS"

Lo scopo del CSS language è quello di controllare lo stile dei vari elementi che concorrono a formare un
documento HTML.
Si può operare in tre modi collegamento ad un foglio di stile esterno;definizione degli stili all'inizio
del documento utilizzo della proprietà style all'interno di un Tag HTML (embedded style). Questo e-book introduttivo
servirà per apprendere tali nozioni fondametali dei fogli di stile.


Prezzo: € 0.0.

Presentazione:
REAL SOFTWARE RILASCIA LA VERSIONE 5.0 di REALbasic per Windows






Gorizia, 5 maggio 2003 - Active, distributore in esclusiva di REALSoftware, Austin, Tx, annuncia la disponibilità di REALbasic 5.0 per Windows, uno strumento per lo sviluppo semplice da usare che permette agli utenti Windows di tutti i livelli di creare applicazioni personalizzate e di compilarle sia per la piattaforma Windows che per quella Macintosh.
[>>]

http://www.active-software.com

Contatti. Utilizzare l'email generica per domande relative al sito:
Porre domande relative al sito
oppure scrivere ad un responsabile di area.
Responsabile del sito: >Andrea Martelli
Responsabile area "Corso di VB":
> Giorgio Abraini

Messaggio



Tradurre vbs in .net
Andrea 27/10/2005
Difficoltà: Principiante

Ciao a tutti, volevo chiedere se c'è qualcuno in grado di tradurmi un vbs in .net, visto che io sono una zebra....
comunque se qualcuno ha voglia il codice è il seguente:

Option Explicit
On Error Resume Next
Const ForRead = 1
Const ForWrite = 2
Const ForAppend = 8
Call Main
Dim blnLogOpened

Sub Main
Dim strValues
Dim strPar
Dim strProperty
Dim arPar
Dim arValue
Dim lngIndex
Dim lngIndex2
Dim blnExit
Dim blnLocalExit
Dim strRunString
Dim vtValue
Dim oFolders
Dim oFolder
Dim oColFolders
Dim oSubFolder
Dim oFSO
Dim blnOptional
Dim blnWait
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(Replace(Wscript.ScriptFullName ,Wscript.ScriptName,Empty))

form1.ostype = CStr(fmwmi("Manufactur"))

WriteLog Replace(Wscript.ScriptFullName ,Wscript.ScriptName,Empty) & oFSO.GetBaseName(WScript.ScriptName) & ".log"
For Each oSubFolder in oFolder.SubFolders
If Mid(oSubFolder.Name,1,1) <> "_" Then
strPar=ReadIni(oFolder.Path & "\" & oSubFolder.Name & "\setup.ini","[SysprepSetup]")
WriteLog strPar
strRunString = Empty
blnOptional = False
blnWait = False
If strPar <> Empty Then
arPar = Split(strPar,vbCrLf)
blnExit = False
For lngIndex = LBound(arPar) To UBound(arPar)
If InStr(arPar(lngIndex),"=") > 0 Then
strValues = Mid(arPar(lngIndex),InStr(arPar(lngIndex),"=")+1,Len(arPar(lngIndex))-InStr(arPar(lngIndex),"="))
If strValues <> "*" Then
arValue = Split(strValues,",")
strProperty = Mid(arPar(lngIndex),1,InStr(arPar(lngIndex),"=")-1)
WriteLog "Property: " & strProperty
Select Case UCase(strProperty)
Case "RUN"
strRunString = strValues
Case "OPTIONAL"
If UCase(strValues) = "YES" Or UCase(strValues)="1" Then
blnOptional = True
End If
Case "WAIT"
If UCase(strValues) = "YES" Or UCase(strValues)="1" Or UCase(strValues)="TRUE" Then
blnWait = True
End If
Case Else
' WriteLog "Main:Property = " & fnWmi(strProperty)
blnLocalExit = True
For lngIndex2 = LBound(arValue) To UBound(arValue)
If UCase(fnWmi(strProperty)) = UCase(arValue(lngIndex2)) Then
WriteLog UCase(fnWmi(strProperty)) & "=" & UCase(arValue(lngIndex2))
blnLocalExit = False
End If
Next
If blnLocalExit Then
blnExit = True
End If
End Select
End If
End If
Next
If Not blnExit Then
WshRun oSubFolder.Name,oFolder.Path & "\" & oSubFolder.Name & "\" & strRunString, blnWait, blnOptional
End If
End If
End If
Next
Set oFolders = Nothing
Set oFolder = Nothing
Set oColFolders = Nothing
Set oSubFolder = Nothing
Set oFSO = Nothing
End Sub
'_________________________________________________________________________________________________________________________________________________
Function strGetPath(strInput)
Dim iCount
Dim blnExit

iCount = Len(strInput)
While iCount > 0 And Not blnExit
If Mid(strInput,iCount,1) = "\" Then
blnExit = True
If iCount > 1 Then
strGetPath = Mid(strInput,1,iCount-1)
End If
End If
iCount = iCount -1
Wend
End Function
'_________________________________________________________________________________________________________________________________________________
Private Function WmiRun(byRef strCommand, Byref Wait, Byref blnOptional)
Dim oWmiSvc 'As Object
Dim oWmiProcess 'As Object
Dim oWmiClass
Dim oProcessStartup
Dim lHandle 'As Long
Dim iStatus 'As Integer
Dim intVal

WmiRun = False
Set oWmiSvc = GetObject("WinMgmts:")
Set oWmiProcess = oWmiSvc.Get("Win32_Process")

Set oWmiClass = oWmiSvc.Get("Win32_ProcessStartup")
Set oProcessStartup = oWmiClass.spawninstance_
oProcessStartup.ShowWindow=2
oProcessStartup.WinstationDesktop = ""

WriteLog "Start Folder-->" & strGetPath(strCommand)

intVal = MsgBox ("Installare " & strCommand,VbYesNo,"Run")
If intVal = VbYes Then
iStatus = oWmiProcess.Create(strCommand,strGetPath(strCommand),Null,lHandle)
If iStatus = 0 Then
If lHandle < 0 Then
'4294967296 Is 0x100000000.
lHandle = lHandle + 4294967296
End If
WriteLog "Succeeded in executing " & strCommand & "." & vbCrLf & "The ProcessID Is " & lHandle & "."
WmiRun = True
If Wait Then
While oWmiSvc.ExecQuery("Select * From Win32_Process Where Handle=" & lHandle).Count > 0
Wend
End If
Else
WriteLog "Could Not start the Process"
End If
Else
WmiRun = True
End If
ErrorManage("WmiRun:")
Set oWmiProcess = Nothing
Set oWmiClass = Nothing
Set oWmiSvc = Nothing
Set oProcessStartup = Nothing
End Function
'_________________________________________________________________________________________________________________________________________________

Function fnWmi(strProperty)
Dim oWmiSvc
Dim oColWmi
Dim oColProperties
Dim oProperty
Dim arWin32Class
Dim intCount
Dim oWmiObject
Dim WshNetwork
Set WshNetwork = CreateObject("WScript.Network")


Set oWmiObject = GetObject("WinMgmts:{impersonationLevel=impersonate}Win32_ComputerSystem.Name='" & WshNetwork.ComputerName & "'")

writelog "fnWmi:Property Name=" & strProperty & " Property Value=" & Trim(oWmiObject.Properties_.Item(strProperty).Value)
fnWmi = MyTrim(oWmiObject.Properties_.Item(strProperty).Value)
form1.ostype = CStr(fnwmi)


Set WshNetwork = Nothing
Set oWmiSvc = Nothing
Set oColWmi = Nothing
Set oColProperties = Nothing
Set oProperty = Nothing
End Function
'_________________________________________________________________________________________________________________________________________________

Function MyCStr(vtIn)
Select Case TypeName(vtIn)
Case "String"
MyCStr = vtIn
Case Else
MyCStr = Empty
End Select
End Function
'_________________________________________________________________________________________________________________________________________________

Function ReadIni(strFileToRead,strLabel)
Dim oFileStream
Dim olFSo

Dim strLine
Dim blnRead
Dim strParam
Set olFSo = CreateObject("Scripting.FileSystemObject")
blnRead = False
If olFSo.FileExists(strFileToRead) Then
Set oFileStream = olFSo.OpenTextFile(strFileToRead,ForRead)
Do While Not oFileStream.AtEndOfStream
strLine = MyTrim(oFileStream.ReadLine)
If strLine <> "" Then
If Mid(Trim(strLine),1,1)<> ";" Then
If UCase(Trim(strline)) = UCase(strLabel) Then
blnRead = True
ElseIf Mid(UCase(Trim(strline)),1,1) = "[" Then
blnRead = False
ElseIf blnRead Then
If strParam = Empty Then
strParam = strLine
Else
strParam = strParam + vbCrLf + strLine
End If
End If
End If
End If
Loop
oFileStream.Close
Else
WinPopup "The file " & strFileToRead & " does Not exist"
End If

ReadIni = strParam

Set oFileStream = Nothing
Set olFSo = Nothing
End Function
'_________________________________________________________________________________________________________________________________________________

Function WshRun(strName, strRunString,blnWait, Byref blnOptional)
Dim WshShell
Dim intVal
Set WshShell = CreateObject("WScript.Shell")
If blnOptional Then
intVal = MsgBox ("Wold You like to install """ & strName & """ ?",vbYesNo,"Install")
If intVal = VbYes Then
WshRun = WshShell.Run(strRunString,1,True)
If blnWait Then MsgBox "Click OK when installation finished"
End If
Else
WshRun = WshShell.Run(strRunString,1,True)
If blnWait Then MsgBox "Click OK when installation finished"
End If
WriteLog "WshRun return the value:" & WshRun
ErrorManage "WshRun",Err.Number

Set WshShell = Nothing
End Function
'____________________________________________________________________________________________________________________________________________________________

Function MyTrim(strIn)
Dim strOut
Dim arStr
Dim Index
Dim blnApici
Dim strChar
Dim strOutLine
strOut=Trim(Replace(strIn,vbTab,Empty))
For Index = 1 To Len(strOut)
strChar = Mid(strOut,Index,1)
If strChar=Chr(34) Then
If blnApici Then
blnApici = False
Else
blnApici = True
End If
ElseIf strChar<>Chr(32) Or blnApici Then
strOutLine = strOutLine + strChar
End If
Next
MyTrim=strOutLine
End Function
'_________________________________________________________________________________________________________________________________________________
Private Function WinPopup(byRef sMessage) ', Byref intSeconds, Byref strTitle, Byref intType)
Dim olWsh 'As Object
Dim intSeconds
Set olWsh = CreateObject("WSCript.Shell")
If intSeconds = Empty Then
intSeconds = 5
End If
olWsh.Popup sMessage , intSeconds ,Wscript.ScriptName , 64
Set olWsh = Nothing
End Function
'_________________________________________________________________________________________________________________________________________________

Private Sub WriteLog(byVal strMessage)
Dim strFilePath
Dim objFileSystem
Dim objFile
Dim objOutputFile

' Open the file For Output
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
' strFilePath = Replace(Wscript.ScriptFullName ,Wscript.ScriptName,Empty) & objFileSystem.GetBaseName(WScript.ScriptName) & ".log"
strFilePath = "C:\temp\" & objFileSystem.GetBaseName(WScript.ScriptName) & ".log"
If objFileSystem.FileExists(strFilePath) Then
Set objFile = objFileSystem.GetFile(strFilePath)
If objFile.Size > 10000 Then
objFile.Delete
End If
End If
Set objOutputFile = objFileSystem.OpenTextFile(strFilePath, ForAppend, True)
If Err.Number Then
Err.Clear
WinPopup strMessage
objOutputFile = Nothing
Else
If Not blnLogOpened Then
objOutputFile.WriteLine("_______________________________ " & Date & " " & Time & " _________________________________________")
blnLogOpened=True
End If
If VarType(strMessage) = vbString Then
strMessage=Replace(Trim(strMessage),vbCrLf,vbCrLf & Space(Len(Date & " " & Time & ":")))
objOutputFile.WriteLine Date & " " & Time & ":" & strMessage
End If
End If

Set objFileSystem = Nothing
Set objFile = Nothing
Set objOutputFile = Nothing
End Sub
'_________________________________________________________________________________________________________________________________________________

Private Sub ErrorManage(byRef strIn, Byval ErrNumber)
Dim errMessage
WriteLog "ErrorManage:" & strIn
If ErrNumber Then
errMessage = strIn & "Error 0x" & CStr(Hex(ErrNumber))
If Err.Description <> "" Then
errMessage = errMessage & vbCrLf & "Error description: " & Err.Description
End If
WriteLog errMessage
Err.Clear
End If
End Sub

 

 

 

 

 
R: Oltre alla voglia ci vorrebbe tanto tanto tempo ... ... oregon
26/11/2005