Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch to VB6  (Read 2852 times)

0 Members and 1 Guest are viewing this topic.

hamoody3

    Topic Starter


    Greenhorn

    Batch to VB6
    « on: February 25, 2010, 03:41:07 AM »
    Hi
    I have this batch file code:

    @echo off
    :MAIN
    set password=bibo
    echo Welcome to SMARTIA. Please enter the password.
    set /p input=Password:
    if %input%==%password% start Psp.exe

    when I run it, it gives me what I want but in the DOS poor interface. Can VB6 do the same task with its good interface? and can I add an ELSE statement to write (Sorry, incorrect password). If possible please show me the way

    thanks

    Treval



      Hopeful

      Thanked: 14
      Re: Batch to VB6
      « Reply #1 on: February 25, 2010, 06:59:58 AM »

      I don't know any VB6 so I did it in Visual Basic .NET in Visual Studio.
      I hope you (or someone else) can translate it to VB6. =)

      Here is the code:

      Code: [Select]
      Public Class Smartia

          Dim password As String = "bibo"

          Public Sub New()
              ' This call is required by the Windows Form Designer.
              InitializeComponent()

              ' Add any initialization after the InitializeComponent() call.
              lblWelcome.Text = "Welcome to SMARTIA. Please enter the password."
          End Sub

          Private Sub txtpw_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtpw.KeyDown
              If Not e.KeyCode = Keys.Enter Then
                  Return
              End If
              If txtpw.Text = password Then
                  lblSorry.Text = ""
                  txtpw.Text = ""
                  Dim RetVal As Object = Shell("C:\WINDOWS\System32\calc.exe", 1)
              Else
                  lblSorry.Text = "Sorry. Wrong password"
              End If
          End Sub
      End Class

      Screenshot:
      screenshot 1
      screenshot 2

      Treval