vbscript HTML5输入类型日期 - 为日期选择器指定默认值

HTML5输入类型日期 - 为日期选择器指定默认值

HTML5InputTypeDefaultDateSpecifier.vbs
Dim dAnyDate As Date
Dim sHTML5DateInputTypeFormatedString As String 

'Keeping it simple here 
sHTML5DateInputTypeFormatedString = dAnyDate.ToString("yyyy-MM-dd")

'You have to format it this way (YYYY-MM-DD) to specify the default 
<input type="date" value="@sHTML5DateInputTypeFormatedString">  

vbscript 了解批次是否在过去X小时内执行过

了解批次是否在过去X小时内执行过

do_job_every_X_hours.bat
@echo off

pushd %~dp0
::sync
start /wait "" cmd /c cscript date.vbs
::async - debug
::start /b "" cscript date.vbs

if %errorlevel% EQU 0 (
	echo it's been less than 24 hours
	goto :eof
)

echo it's been more than 24 hours since last execution
::here we would execute the task
date.vbs
'################ name it date.vbs #################
Function Write(data, outFile)
	Set objFSO=CreateObject("Scripting.FileSystemObject")
	Set objFile = objFSO.CreateTextFile(outFile,True)
	objFile.Write data & vbCrLf
	objFile.Close
	
End Function

Function ReadDate()
	Set objFSO=CreateObject("Scripting.FileSystemObject")
	strFile="time.log"
	Set objFile = objFSO.OpenTextFile(strFile)
	Do Until objFile.AtEndOfStream
		strLine= objFile.ReadLine
		'Wscript.Echo strLine
	Loop
	objFile.Close
	ReadDate = strLine
End Function

Function HoursDiff(dt1, dt2) 
        If (isDate(dt1) And IsDate(dt2)) = false Then 
            TimeSpan = "00:00:00" 
            Exit Function 
        End If 

        HoursDiff = Abs(DateDiff("H", dt1, dt2)) 
End Function 

    oldDate = ReadDate() 'last Date
    d2 = Now() 
    
    h = HoursDiff(oldDate, d2) 
   
	Escriu d2, "time_last_try.log" 'we write the last try
  
If h < 24 Then 'change this if you want something
	Wscript.quit(0) 'retruns 0 if it has been executed the last 24 hours
Else
	Wscript.echo "writing new date"
	Write d2, "time.log"
	Wscript.quit(1) 'retruns 1 if it has been more than 24 hours since the last execution
End If

vbscript 了解批次是否在过去X小时内执行过

了解批次是否在过去X小时内执行过

do_job_every_X_hours.bat
@echo off

pushd %~dp0
::sync
start /wait "" cmd /c cscript date.vbs
::async - debug
::start /b "" cscript date.vbs

if %errorlevel% EQU 0 (
	echo it's been less than 24 hours
	goto :eof
)

echo it's been more than 24 hours since last execution
::here we would execute the task
date.vbs
'################ name it date.vbs #################
Function Write(data, outFile)
	Set objFSO=CreateObject("Scripting.FileSystemObject")
	Set objFile = objFSO.CreateTextFile(outFile,True)
	objFile.Write data & vbCrLf
	objFile.Close
	
End Function

Function ReadDate()
	Set objFSO=CreateObject("Scripting.FileSystemObject")
	strFile="time.log"
	Set objFile = objFSO.OpenTextFile(strFile)
	Do Until objFile.AtEndOfStream
		strLine= objFile.ReadLine
		'Wscript.Echo strLine
	Loop
	objFile.Close
	ReadDate = strLine
End Function

Function HoursDiff(dt1, dt2) 
        If (isDate(dt1) And IsDate(dt2)) = false Then 
            TimeSpan = "00:00:00" 
            Exit Function 
        End If 

        HoursDiff = Abs(DateDiff("H", dt1, dt2)) 
End Function 

    oldDate = ReadDate() 'last Date
    d2 = Now() 
    
    h = HoursDiff(oldDate, d2) 
   
	Escriu d2, "time_last_try.log" 'we write the last try
  
If h < 24 Then 'change this if you want something
	Wscript.quit(0) 'retruns 0 if it has been executed the last 24 hours
Else
	Wscript.echo "writing new date"
	Write d2, "time.log"
	Wscript.quit(1) 'retruns 1 if it has been more than 24 hours since the last execution
End If

vbscript 获取的Windows系统当前序列号

获取的Windows系统当前序列号

new_gist_file.vbs
Dim s
s = InputBox("当前Windows系统序列号为:", "Windows序列号", GetWindowsSN)
WScript.Quit


'取得当前Windows序列号函数

Function GetWindowsSN()
    Const HKEY_LOCAL_MACHINE = &H80000002
    strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    strValueName = "DigitalProductId"
    strComputer = "."
    Dim iValues()
    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    oReg.GetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, iValues
    Dim arrDPID
    arrDPID = Array()
    For i = 52 To 66
        ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
        arrDPID( UBound(arrDPID) ) = iValues(i)
    Next
    ' <--------------- Create an array to hold the valid characters for a microsoft Product Key -------------------------->
    Dim arrChars
    arrChars = Array("B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", "T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9")

    ' <--------------- The clever bit !!! (Decrypt the base24 encoded binary data)-------------------------->
    For i = 24 To 0 Step -1
        k = 0
        For j = 14 To 0 Step -1
            k = k * 256 Xor arrDPID(j)
            arrDPID(j) = Int(k / 24)
            k = k Mod 24
        Next
        strProductKey = arrChars(k) & strProductKey
        ' <------- add the "-" between the groups of 5 Char -------->
        If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey
    Next
    GetWindowsSN = strProductKey
End Function

vbscript Word宏迭代表中的每个单元格并将数据提取到文本文件。

Word宏迭代表中的每个单元格并将数据提取到文本文件。

C# Word Table Cell.vbs
Private Sub Document_New()

End Sub

Sub RetrieveTableItems()

   Dim oRow As Row
   Dim oCell As Cell
   Dim sCellText As String
   Dim i As Integer
   Dim strLine As String
   Dim strLines As String
   
   Dim OutputFileNum As Integer
   ' Turn on error checking.
   On Error GoTo ErrorHandler

   ' Loop through each row in the table.
   i = 1
   For Each oRow In ActiveDocument.Tables(1).Rows

      ' Loop through each cell in the current row.
      If i > 2 Then
      For Each oCell In oRow.Cells
         
            sCellText = oCell.Range
            ' Remove table cell markers from the text.
            sCellText = Left$(sCellText, Len(sCellText) - 2)
            
            strLine = strLine + sCellText + "|"
      Next oCell
    End If
    strLines = strLines + strLine + "^"
    strLine = ""
    i = i + 1
   Next oRow
OutputFileNum = FreeFile
Open "C:\Ahold\ChangeLog.txt" For Output Lock Write As #OutputFileNum
Print #OutputFileNum, strLines
Close OutputFileNum
MsgBox "Complete "

ErrorHandler:
   If Err <> 0 Then
      Dim Msg As String
      Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description _
         & Chr(13) & "Make sure there is a table in the current document."
         MsgBox Msg, , "Error"
   End If

End Sub


vbscript [.net] VB.NET笔记

[.net] VB.NET笔记

.NET Notes.vbs
'-----------------------------------
'MULTI-DIMENSIONAL ARRAY
'-----------------------------------

'*** Create Array and append values to it
Dim itemsArray As String()() = New String(0)() {}
For i = 1 To 3
  ReDim Preserve itemsArray(i)
  itemsArray(i) = New String() {"1", "2", "3"}
Next

'Output:
'  1 2 3
'  1 2 3
'  1 2 3

'*** Free array's memory
Array.Clear(itemsArray, 0, itemsArray.Length)
Erase itemsArray


'-----------------------------------
'NUMBER FORMATTING
'-----------------------------------

Dim FormattedNumber As String = String.Format("{0:N0}", 123456)
'Output: 123,456

'*** Decimals:
'use 'F' fixed point format with '3' decimal places.
Dim PrintableNumber As String = String.Format("{0:F3}", 0.126467382626182)
'Output: 0.126

'*** Padding:
'The 'D' means padded decimal integer and the '4' means to 4 places, 
'so you end up with a 4 digit printable number that's prefixed with 0's where needed.
Dim Result As Integer = 20
Dim PrintableNumber As String = String.Format("{0:D4}", Result)
'Output: 0020


'-----------------------------------
'DATE & TIME FORMATTING
'-----------------------------------

Dim MyDate As String = String.Format("{0}", DateTime.Now)
'Output: 14/04/2014 13:47:32
'Which will be formatted according to your local culture settings.

'Just as with the number formatting strings, there is a wide range of possible operators 
'you can use here to get just the format you need; for example:
Dim MyDate As String = String.Format("{0:r}", DateTime.Now)
'Output: Mon, 14 Apr 2014 13:52:41 GMT

'Where as:
Dim MyDate As String = String.Format("{0:s}", DateTime.Now)
'Output: 2014-04-14T13:53:37

'Custom formatting:
Dim MyDate As String = String.Format("{0:yyyy - dd MMMM @ hh:mm tt}", DateTime.Now)
'Output: 2014 - 14 April @ 01:57 PM



vbscript vb_finger_print.vb

vb_finger_print.vb
// https://www.daniweb.com/software-development/vbnet/threads/472214/how-to-match-a-fingerprint-template-from-database-
Dim fingerprintData As MemoryStream = New MemoryStream
        Template.Serialize(fingerprintData)
        fingerprintData.Position = 0
        Dim br As BinaryReader = New BinaryReader(fingerprintData)
        Dim bytes() As Byte = br.ReadBytes(CType(fingerprintData.Length, Int32))
        Dim cmd As SqlCommand = New SqlCommand("INSERT INTO fininger_table VALUES(@FIRSTNAME, @LASTNAME, @FINGERPRINT)", conn)
        cmd.Parameters.Add("FIRSTNAME", SqlDbType.VarChar).Value = CaptureForm.tboxFname.Text
        cmd.Parameters.Add("LASTNAME", SqlDbType.VarChar).Value = CaptureForm.tboxLname.Text
        cmd.Parameters.Add("FINGERPRINT", SqlDbType.Image).Value = bytes
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()




 conn.Open()
        Dim cmd As New SqlCommand("SELECT * FROM Fininger_table", conn)
        Dim rdr As SqlDataReader = cmd.ExecuteReader()
        Dim MemStream As IO.MemoryStream
        Dim fpBytes As Byte()
        While rdr.Read()
            fpBytes = rdr("FINGERPRINT")
            MemStream = New IO.MemoryStream(fpBytes)
            Dim template As New DPFP.Template(MemStream)
            OnTemplate(template)
            ' template.DeSerialize(MemStream)
        End While
        rdr.Close()
        conn.Close()

vbscript Visual Basic 2013 Mysql数据库连接

Visual Basic 2013 Mysql数据库连接

mysql2.vb
Private Sub buttonRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonRegister.Click

        'Does user already exists
        Dim bUserExists As Boolean = _Users.UserExists(New UserID(textBoxUserName.Text))

        ' first make sure the user is created if new user
        If _ActiveUser Is Nothing Or Not bUserExists Then
            ' initialize with supplied user name
            _ActiveUser = New User(textBoxUserName.Text)
        Else
            ' update active user if not as originally selected
            If bUserExists And Not listBoxUsers.SelectedItem.ToString() = textBoxUserName.Text Then
                _ActiveUser = _Users(New UserID(textBoxUserName.Text))
            End If
        End If

        ' and check if the template already exists for the assigned finger
        If _ActiveUser.TemplateExists(_AssignedFinger) Then
            ' show message indicating template already exists for selected finger
            Dim diagResult As DialogResult = MessageBox.Show(Me, [String].Format("Oops!" + ControlChars.Cr + ControlChars.Lf + "{0} has a template enrolled to his/her {1} finger." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "Shall the old template be discarded?", _ActiveUser.ID.ToString(), _Fingers(_AssignedFinger)), "Template already assigned!", MessageBoxButtons.YesNo, MessageBoxIcon.Error)

            ' if user selected not to overwrite, then abort
            If diagResult = Windows.Forms.DialogResult.No Then
                Return
            End If
        End If

        Try
            ' attempt to read the template
            Dim templateOpened As New DPFP.Template(File.OpenRead(textBoxTemplateFilename.Text))

            ' run a template duplicate check
            IdentifyTemplate(templateOpened)

            ' remove the old template if exists
            If _ActiveUser.TemplateExists(_AssignedFinger) Then
                ' removed from assigned finger
                _ActiveUser.RemoveTemplate(_AssignedFinger)
            End If

            ' and assign it to the user as specified
            _ActiveUser.AddTemplate(templateOpened, _AssignedFinger)

            ' update collection
            If Not _Users.UserExists(_ActiveUser.ID) Then
                ' update list box
                listBoxUsers.Items.Add(_ActiveUser.ID.ToString())

                ' add user it to the user collection
                _Users.AddUser(_ActiveUser)
            End If

            ' success
            UpdateEventLog([String].Format("{0}: Template successfully assigned to {1} finger.", _ActiveUser.ID.ToString(), _AssignedFinger.ToString()))

            ' turn off groupbox
            groupAddTemplate.Visible = False

            listBoxUsers.SelectedItem = _ActiveUser.ID.ToString()

            ' sync gui
            _syncUI()

            ' view user
            _syncViewUser()

        Catch Err As DPFP.Error.SDKException
            ' log message
            UpdateEventLog(Err.ToString())
            System.Diagnostics.Trace.WriteLine(Err.ToString())
        Catch Err As System.IO.FileNotFoundException
            ' log message
            UpdateEventLog("Template file not found or is inaccessible.")
            System.Diagnostics.Trace.WriteLine(Err.ToString())
        Catch Err As Exception
            ' log message
            UpdateEventLog(Err.ToString())
            System.Diagnostics.Trace.WriteLine(Err.ToString())
        End Try

        Using conn As New MySqlConnection("Server = localhost; Username= root; Password =; Database = vb")
            Using cmd
                With cmd
                    MsgBox("Connection Established")
                    .Connection = conn
                    .Parameters.Clear()
                    'Create Insert Query
                    .CommandText = "INSERT INTO employees(UserID, Name, Finger) VALUES (@iID, @iName, @iFinger)"
                    .Parameters.Add(New MySqlParameter("@iID", ID.Text))
                    .Parameters.Add(New MySqlParameter("@iName", textBoxUserName.Text))
                    .Parameters.Add(New MySqlParameter("@iFinger", comboBoxAssignedFinger.Text))


                End With
                Try
                    'Open Connection and Execute Query
                    conn.Open()
                    cmd.ExecuteNonQuery()
                Catch ex As MySqlException
                    MsgBox(ex.Message.ToString())
                End Try
            End Using
        End Using
Form1.vb
Imports MySql.Data.MySqlClient
Public Class Form1
    Public dbconn As New MySqlConnection
    Public sql As String
    Public dbcomm As MySqlCommand
    Public dbread As MySqlDataReader

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        dbconn = New MySqlConnection("Data Source=localhost;userid=root;database=vb;")
        Try
            dbconn.Open()
        Catch ex As Exception
            MsgBox("Error in connection, please check Database and connection server.")
        End Try

    End Sub

    Private Sub btn_save_Click(sender As Object, e As EventArgs) Handles btn_save.Click
        sql = "INSERT INTO users(username) VALUES('" & text_user_name.Text & "')"
        Try
            dbcomm = New MySqlCommand(sql, dbconn)
            dbread = dbcomm.ExecuteReader()
            dbread.Close()
        Catch ex As Exception
            MsgBox("Error in saving to Database. Error is :" & ex.Message)
            dbread.Close()
            Exit Sub
        End Try
        MsgBox("The User Name was saved.")
        text_user_name.Text = ""
    End Sub

    Private Sub btn_get_Click(sender As Object, e As EventArgs) Handles btn_get.Click
        list_users.Items.Clear()
        sql = "SELECT * FROM users"
        Try
            dbcomm = New MySqlCommand(sql, dbconn)
            dbread = dbcomm.ExecuteReader()

            While dbread.Read
                list_users.Items.Add(dbread("username"))
            End While

            dbread.Close()
        Catch ex As Exception
            MsgBox("Error in collecting data from Database. Error is :" & ex.Message)
            dbread.Close()
            Exit Sub
        End Try
    End Sub
End Class

vbscript 如何在ASP.NET中动态包含文件http://support.microsoft.com/default.aspx?scid=KB;EN-US;q306575&ID=KB;EN-US;q306575

如何在ASP.NET中动态包含文件http://support.microsoft.com/default.aspx?scid=KB;EN-US;q306575&ID=KB;EN-US;q306575

include-file.vbs
<%@ Page Language="vb" AutoEventWireup="false"%>
<html>
<body>

<% Response.WriteFile ("Yourfile.inc") %>

</body>
</html>

vbscript 数据透视表:编辑

数据透视表:编辑

FilterBLANK.vbs
Sub FilterBLANK()
On Error Resume Next
ActiveSheet.PivotTables("PivotTable1").PivotFields("First Name").PivotFilters.Add Type:=xlCaptionEquals, Value1:=""
End Sub
ClearFILTER.vbs
Sub ClearFILTER()
On Error Resume Next
ActiveSheet.PivotTables("PivotTable1").PivotFields("Job Title").ClearAllFilters
End Sub