Search code examples
imagevbscriptpasswordsmessagebox

VBS password protected image


I'm not a programmer and i need help. How to combine this two scripts into one? Then i will convert this to EXE and give as present on Tank Style pendrive :).

pass=inputbox("Password?")
if pass="fish" then msgbox("Correct Password!") else msgbox("Incorrect Password!")

AND

Set objExplorer = CreateObject("InternetExplorer.Application")

With objExplorer "
    .Navigate "about:blank"
    .ToolBar = 0
    .StatusBar = 0
    .Left = 200
    .Top = 200
    .Width = 650
    .Height = 440
    .Visible = 1
    .Document.Title = "Kocham cie Maciek!"
    .Document.Body.InnerHTML = _
        "<center>Kocham cie Maciek <3<br><br><img src='http://www.crystalclearsports.net/file/2016/07/use_love_quotes_for_him_and_inspire_romantic_vitality.jpg' height=336 width=600></center>"
" 
End With

When someone type good password it show Picture1, if bad Picture2.


Solution

  • Try this!

    Dim MyPassword, objExplorer
    MyPassword = InputBox("Enter the Password and Press 'OK' ", "Password")
    MyPassword = Trim(MyPassword) 
    
    If MyPassword = "" Then
        Msgbox "No Password is entered"
    Else
        Set objExplorer = CreateObject("InternetExplorer.Application")
        With objExplorer 
            .Navigate "about:blank"
            .ToolBar = 0
            .StatusBar = 0
            .Left = 200
            .Top = 200
            .Width = 650
            .Height = 440
            .Visible = 1
            .Document.Title = "Kocham cie Maciek!"
        End With 
        If StrComp(MyPassword, "FISH", 1) = 0 Then
            ' Correct Password
            Msgbox "The Password is Correct"
            objExplorer.Document.Body.InnerHTML = "<center>Kocham cie Maciek <3<br><br><img src='http://www.crystalclearsports.net/file/2016/07/use_love_quotes_for_him_and_inspire_romantic_vitality.jpg' height=336 width=600></center>'" 
        Else
            Msgbox "Incorrect Password"
            objExplorer.Document.Body.InnerHTML = "<center>Kocham cie Maciek <3<br><br><img src='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' height=336 width=600></center>'" 
        End If
    End if 
    

    you missed the second image, update the XXXX with the location of second image you would want to show!!