私はこれに取り組んできました...しかし、なぜそれが機能するのかわかりません
ドロップダウンリストがあり、選択すると値が設定されますが、うまくいきました...
しかし、その値を別のサブルーチンに表示したい場合、表示されませんか?
私を助けてください ?
そして、コードを特定の方法で書く必要がある場合は、私に知らせてください...私はインターネットから学んでいるので、適切に「訓練」されていません....
<html>
<head>
<title>Break Logs</title>
<HTA:APPLICATION
icon=icon.ico
singleinstance="yes"
border="thin"
borderStyle="normal"
caption="yes"
maximizeButton="no"
minimizeButton="no"
showInTaskbar="yes"
windowState="normal"
innerBorder="yes"
navigable="no"
scroll="no"
scrollFlat="no"
sysMenu="yes"
>
</head>
<SCRIPT Language="VBScript">
Window.ResizeTo 250, 250
Dim objFSO, wshShell, strUser, Name, LastName, strLogs, strLogFile, strLocation
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GETTING USERS NAME FROM AD THIS IM NOT USING WHEN AT HOME TESTING...
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub asdf
Set wshShell = CreateObject("WScript.Shell")
strUser = wshShell.ExpandEnvironmentStrings("%USERNAME%")
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomain = objRootDSE.Get("DefaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://" & strDomain & "' WHERE objectCategory='User' AND samAccountName = '" & strUser & "'"
Set objRecordSet = objCommand.Execute
If Not objRecordSet.EOF Then
strDN = objRecordSet.Fields("distinguishedName").Value
End If
Set MyUser = GetObject ("LDAP://" & strDN)
Name = myUser.GivenName
LastName = myUser.sn
end sub
Name = "Pavle"
LastName = "Stojanovic"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SETTING TITLEBAR NAME
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
document.title = "Break Logs For " & Name & " " & LastName
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CONST ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
strLocation = "F:\"
strLogFile = "Late Breaks.txt"
If Not objFSO.FileExists(strLocation & strLogFile) Then
objFSO.CreateTextFile(strLocation & strLogFile)
End If
Sub Breaks
MorningBreak = (" - Morning Break " & Name & " was late: " & _
HowLate.Value & " Minutes" & vbCrLf & _
" - Reason: " & Reason.Value & vbCrLF & _
" - Date Entered: " & Now())
LunchBreak = (" - Lunch Break " & Name & " was late: " & _
HowLate.Value & " Minutes" & vbCrLf & _
" - Reason: " & Reason.Value & vbCrLF & _
" - Date Entered: " & Now())
AfternoonBreak = (" - Afternoon Break " & Name & " was late: " & _
HowLate.Value & " Minutes" & vbCrLf & _
" - Reason: " & Reason.Value & vbCrLF & _
" - Date Entered: " & Now())
RNA = (" - Ring No Answer Logged By " & Name & vbCrLF & _
" - On Date: " & Now() & vbCrLF & _
" - Reason: " & Reason.Value)
Other = (" - Date Entered: " & Now() & vbCrLf & _
" - Reason: " & Reason.Value)
If DropDown.Value = 1 Then
' Nothing to be done in this option...
ElseIf DropDown.Value = 2 Then
BreakCode = MorningBreak
ElseIf DropDown.Value = 3 Then
BreakCode = LunchBreak
ElseIf DropDown.Value = 4 Then
BreakCode = AfternoonBreak
ElseIf DropDown.Value = 5 Then
BreakCode = RNA
ElseIf DropDown.Value = 6 Then
BreakCode = Other
Else
MsgBox "Something went wrong, this option shouldn't popup"
End If
' If I do MsgBox to display BreakCode it works here before leaving the sub ?
End Sub
Sub Submit
MsgBox BreakCode ' this doesnt show up and below wont write to text ???
Set strLogs = objFSO.OpenTextFile(strLocation & strLogFile, ForAppending, True)
strLogs.WriteLine BreakCode & vbCrLf
strLogs.Close
End Sub
</SCRIPT>
<body bgColor="LightSteelBlue">
<select size="1" name="DropDown" onChange="Breaks">
<option value="1">Choose Break</option>
<option value="2">Morning Break</option>
<option value="3">Lunch Break</option>
<option value="4">Afternoon Break</option>
<option value="5">Ring No Answer</option>
<option value="6">Other</option>
</select>
<BR>
<BR>
Reason:
<BR>
<input type="text" name="Reason" size="10" style="width:200">
<BR>
<BR>
Minutes Late:
<BR>
<input type="text" name="HowLate" size="10">
<BR>
<BR>
<input type="button" value="Submit" onClick="Submit" title="Added Reason for being late.">
</body>
</html>