Saturday, July 1, 2017

Sum of Two Numbers Using Swing in Java

Hi guys thank you for visiting my site in this article I would like to share with you a sample program that I wrote using Netbeans and Swing in Java. I called this program sum of two numbers using swing in Java. The code is very simple and easy to understand. From my experience writing a GUI application for desktop application in Netbeans is very easy and simple I hope you will find my work uesful. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.








Sample Program Output


Program Listing

sum_two.java


import javax.swing.JOptionPane;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Jacob
 */
public class sum_two extends javax.swing.JFrame {

    /**
     * Creates new form sum_two
     */
    public sum_two() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txt_val1 = new javax.swing.JTextField();
        txt_val2 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txt_sum = new javax.swing.JTextField();
        btn_quit = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        btn_sum = new javax.swing.JButton();
        btn_clear1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Enter Value Number One");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel2.setText("Enter Value Number Two");

        txt_val1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        txt_val2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel3.setText("The total sum is");

        txt_sum.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        btn_quit.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btn_quit.setText("Quit");
        btn_quit.setToolTipText("Click here to quit program.");
        btn_quit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_quitActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel4.setText("Sum of Two Numbers in Java Swing");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setText("Created By Mr. Jake R. Pomperada");

        btn_sum.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btn_sum.setText("Sum");
        btn_sum.setToolTipText("Click here to find the sum of two numbers.");
        btn_sum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_sumActionPerformed(evt);
            }
        });

        btn_clear1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btn_clear1.setText("Clear");
        btn_clear1.setToolTipText("Click here to clear the text box.");
        btn_clear1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_clear1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txt_val2)
                    .addComponent(txt_val1)
                    .addComponent(txt_sum, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(btn_sum)
                .addGap(59, 59, 59)
                .addComponent(btn_clear1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btn_quit)
                .addGap(21, 21, 21))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(67, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4))
                .addGap(91, 91, 91))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel4)
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txt_val1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_val2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_sum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_sum)
                    .addComponent(btn_clear1)
                    .addComponent(btn_quit))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(23, 23, 23))
        );

        pack();
    }// </editor-fold>                        

    private void btn_quitActionPerformed(java.awt.event.ActionEvent evt) {                                         
      String message = "Do you want to quit the program?";
      String title = "Really Program Quit?";

    int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
    
    if (reply ==JOptionPane.NO_OPTION)
    {
       this.txt_val1.setText("");
       this.txt_val2.setText("");
       this.txt_sum.setText("");
       
       this.txt_val1.requestFocus();
       
    }
    
    if (reply == JOptionPane.YES_OPTION)
    {
      System.exit(0);
    }
             
    }                                        

    private void btn_sumActionPerformed(java.awt.event.ActionEvent evt) {                                        
        int a = Integer.parseInt(this.txt_val1.getText());
        int b = Integer.parseInt(this.txt_val2.getText());
        
        int total_sum = (a+b);
        
        this.txt_sum.setText(String.valueOf(total_sum));
                
    }                                       

    private void btn_clear1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
       this.txt_val1.setText("");
       this.txt_val2.setText("");
       this.txt_sum.setText("");
       
       this.txt_val1.requestFocus();
       
    }                                          

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(sum_two.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(sum_two.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(sum_two.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(sum_two.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new sum_two().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton btn_clear1;
    private javax.swing.JButton btn_quit;
    private javax.swing.JButton btn_sum;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField txt_sum;
    private javax.swing.JTextField txt_val1;
    private javax.swing.JTextField txt_val2;
    // End of variables declaration                   
}










Monday, June 26, 2017

Addition of Two Numbers Using Model View Controller in PHP

A program that demonstrate how to use the MVC or Model View Controller in PHP to add the sum of two numbers the code is very short and easy to understand. Thank you for visiting the site.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

<?php
/**
 * Created by PhpStorm.
 * User: Jacob Pomperada
 * Date: 6/26/2017
 * Time: 8:24 AM
 */


class Model {
    public $a;
    public $b;

    public function __construct() {
        $this->a=5;
        $this->b=5;
    }
}

class View {
    private $model;

    public function __construct(Model $model) {
        $this->model = $model;
    }

    public function output() {
        echo "<body bgcolor='lightgreen'>";
        echo "<font-face='arial'>";
        echo "<br><br>";
        echo "<span style=\"font-size: 20px !important; font-weight:bold; font-family: arial; color: blue;\">";
        echo "Sum of Two Numbers Using Model View Controller Concepts in PHP </span>";
        echo "<br><br><br>";

        $sum = ($this->model->a + $this->model->b);

        $c = $this->model->a;
        $d = $this->model->b;

        echo "<span style=\"font-size: 20px !important; font-family: arial; font-weight:bold; color: blue;\">";
        echo " The sum of $c and $c is $sum. </span>";
        echo "</font></body>";
    }

}

class Controller {
    private $model;

    public function __construct(Model $model) {
        $this->model = $model;
    }

}

$model = new Model();
$controller = new Controller($model);
$view = new View($model);
if (isset($_GET['action'])) $controller->{$_GET['action']}();
echo $view->output();

?>

Hello World Using Model View Controller Concept in PHP

Here is a program that I wrote using PHP to demonstrate the concept of MVC or Model View Controller this program will display hello world message on the screen. The code is very easy to understand and use. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

hello.php

<?php

class Model {
    public $text;

    public function __construct() {
        $this->text = 'Click Me';
    }
}

class View {
    private $model;

    public function __construct(Model $model) {
        $this->model = $model;
    }

    public function output() {
        echo "<body bgcolor='lightgreen'>";
        echo "<font-face='arial'>";
        echo "<br><br>";
        echo "<h1> Hello World Using Model View Controller Concepts in PHP </h1>";
        echo "<br>";
        return '<a href="demo.php?action=pressme">' . $this->model->text . '</a>';
        echo "</font></body>";
    }

}

class Controller {
    private $model;

    public function __construct(Model $model) {
        $this->model = $model;
    }

    public function pressme() {
        $this->model->text = 'Hello World Mr. Jake Pomperada !!!!';
    }
}


$model = new Model();
$controller = new Controller($model);
$view = new View($model);
if (isset($_GET['action'])) $controller->{$_GET['action']}();
echo $view->output();
?>


Saturday, June 24, 2017

Viewing of User Profile Using Bootstrap, MySQL and PHP

Here is a sample program that I wrote using Twitter Bootstrap, PHP and MySQL which allows that user to view the profile of the user in a company for example the code is very easy to understand and user. I hope you will find my work useful thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.










Sample Program Output






Sunday, June 18, 2017

Address Book in Visual Basic NET and MS Access

Here is my first time to create a complete CRUD application written in Microsoft Visual Basic NET and Microsoft Access I called this program Address Book application to store information and contact numbers of the persons.  The code is very easy to understand and use. I use Microsoft Visual Studio 2012 Ultimate Edition and Microsoft Access 2010.  I hope you will find my work useful. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

Imports System.Data.OleDb
Imports System.IO

Public Class Form1

    Dim strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\vbnet_address\addressbook.accdb;Persist Security Info=False;"
    Dim con As New OleDbConnection
    Dim cmd As New OleDbCommand
    Dim da As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim save_tag As String

    Sub Fill_Grid(grid As Windows.Forms.DataGridView)
        Dim x As Integer

        If grid.Rows.Count > 0 Then
            While x < grid.Rows.Count
                grid.Rows.RemoveAt(x)
            End While
        End If

        With grid
            .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
            .RowHeadersVisible = False
            .SelectionMode = DataGridViewSelectionMode.FullRowSelect
        End With

        con.ConnectionString = strConn
        con.Open()

        With cmd
            .Connection = con
            .CommandType = CommandType.Text
            .CommandText = "SELECT * FROM addressbook"
        End With
        da.SelectCommand = cmd
        grid.DataSource = dt
        da.Fill(dt)

        For i As Integer = 0 To 0
            grid.Columns(i).Visible = False
        Next
        grid.Columns(0).Visible = False

        con.Dispose()
        con.Close()

    End Sub
    Sub save(ByVal tag As String)

        Dim cmdtxt As String = Nothing
        If tag = "new" Then
            cmdtxt = "INSERT INTO addressbook ([personsname], [address], [telephone], [mobile], [email]) " & _
                     "Values('" & UCase(TextBox1.Text) & "','" & UCase(TextBox2.Text) & "','" & UCase(TextBox3.Text) & "','" & UCase(TextBox4.Text) & "','" & LCase(TextBox5.Text) & "' ) "

        ElseIf tag = "edit" Then
            cmdtxt = "UPDATE addressbook SET " & _
                     "[personsname] = '" & UCase(TextBox1.Text.ToString) & "',[address] = '" & UCase(TextBox2.Text) & "', [telephone] = '" & UCase(TextBox3.Text) & "' , [mobile] ='" & UCase(TextBox4.Text) & "' ,[email]='" & LCase(TextBox5.Text) & "' " & _
                     "WHERE ID = " & TextBox6.Text & ""
        End If

        Try

            con.ConnectionString = strConn
            con.Open()

            With cmd
                .Connection = con
                .CommandType = CommandType.Text
                .CommandText = cmdtxt
            End With

            cmd.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical)
        Finally
            con.Dispose()
            con.Close()
        End Try



    End Sub

    Sub delete(ByVal id As Integer)
        Dim cmdtxt As String = Nothing

        cmdtxt = "DELETE FROM addressbook WHERE ID = " & id & ""

        Try
            con.ConnectionString = strConn
            con.Open()

            With cmd
                .Connection = con
                .CommandType = CommandType.Text
                .CommandText = cmdtxt
            End With

            cmd.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical)
        Finally
            con.Dispose()
            con.Close()
        End Try
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label8.Text = DateTime.Now.ToString()
        TextBox6.Visible = False
        save_tag = "new"
        Fill_Grid(DataGridView1)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox1.Text = String.Empty
        TextBox2.Text = String.Empty
        TextBox3.Text = String.Empty
        TextBox4.Text = String.Empty
        TextBox5.Text = String.Empty
        TextBox1.Focus()

        save_tag = "new"
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        save(save_tag)
        Button1.PerformClick()
        Fill_Grid(DataGridView1)

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim id As Integer
        id = Val(TextBox6.Text)
        delete(id)
        Button1.PerformClick()
        Fill_Grid(DataGridView1)
    End Sub

    Private Sub DataGridView1_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
        TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells(1).Value.ToString
        TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells(2).Value.ToString
        TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells(3).Value.ToString
        TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells(4).Value.ToString
        TextBox5.Text = DataGridView1.Rows(e.RowIndex).Cells(5).Value.ToString
        TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells(0).Value.ToString

        save_tag = "edit"

    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Button1.PerformClick()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        If MsgBox("Are you sure you want to quit?", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2, "Close application") = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        End If
        TextBox1.Focus()
    End Sub
End Class





Saturday, June 17, 2017

Login System in Microsoft Visual Basic NET and Microsoft Access

Hi there in this article I started learning how to create a login system using Microsoft Visual Basic NET and Microsoft Access as my database. The code will ask the user to give the username and password and then our program will check if the username and password is really existing in our database if it is true it will display the second windows and greet the user. If the username and password does not exist in the database it will not allow the user to enter in the system. The code is very easy to understand and use. I use Microsoft Visual Studio 2012 Ultimate Edition and Microsoft Access 2010 to write this sample login system. I hope you will find my work useful. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.









Sample Program Output


Program Listing

' Login System in Visual Basic NET
' Written By Mr. Jake R. Pomperada, MAED-IT
' Date: June 17, 2017 Saturday
' Tool : Microsoft Visual Studio Ultimate Edition 2012
' Country of Origin :  Mandaluyong City, Metro Manila Philippines

Imports System.Data.OleDb


Public Class Form1

    Dim provider As String
    Dim dataFile As String
    Dim FirstName As String
    Dim LastName As String
    Dim connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = "
        dataFile = "D:\login_vbnet\login.accdb"


        connString = provider & dataFile

        myConnection.ConnectionString = connString

        myConnection.Open()


        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [login] WHERE [username] = '" & TextBox1.Text & "' AND [password] = '" & TextBox2.Text & "'", myConnection)

        Dim dr As OleDbDataReader = cmd.ExecuteReader


        Dim userFound As Boolean = False

        While dr.Read

            userFound = True

            FirstName = dr("firstname").ToString

            LastName = dr("lastname").ToString

        End While


        If userFound = True Then

            Form2.Show()

            Form2.Label1.Text = "Welcome " & FirstName & " " & LastName

        Else

            MsgBox("Sorry,username or password not found ", MsgBoxStyle.OkOnly, "Invalid Login")

        End If

        myConnection.Close()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        End
    End Sub
End Class





Wednesday, June 14, 2017

Roman Numeral To Decimal Converter in Visual Basic 6

Here is a sample program that I wrote that will ask the user to give a value in Roman Numeral and then it will be converted into its Decimal Equivalent in Visual Basic 6.  Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing

Option Explicit
Dim Rm As String

Public Function ConvertToDecimal(Rm) As Integer
Dim TB
Dim Arab As Integer
Dim i As Byte, A As Integer, Utb As Integer

ReDim TB(0)
    i = 1: Utb = 1
    Rm = Replace(Rm, " ", "") '
    Rm = UCase(Rm) '
    While i <= Len(Rm)
        
        ReDim Preserve TB(Utb)
        A = NBlettre(i)
        TB(Utb) = A * ValueLetters(Mid(Rm, i, 1))
        Debug.Print TB(Utb)
        i = i + A
        Utb = Utb + 1
    Wend
    ReDim Preserve TB(Utb): i = 1
    While i < UBound(TB)
        If TB(i) < TB(i + 1) Then
             Arab = Arab + TB(i + 1) - TB(i)
            i = i + 2
        Else
            Arab = Arab + TB(i)
            i = i + 1
        End If
        Debug.Print Arab
    Wend
    ConvertToDecimal = Arab
End Function
Private Function NBlettre(Deb As Byte) As Byte
Dim i As Integer, L As String
    NBlettre = 1
    L = Mid(Rm, Deb, 1)
    For i = Deb + 1 To Len(Rm)
        If Mid(Rm, i, 1) = L Then
            NBlettre = NBlettre + 1
        Else
            Exit Function
        End If
    Next
End Function

Private Function ValueLetters(L As String) As Integer
Dim Romain, Arabe, i As Byte
    Romain = Array("I", "V", "X", "L", "C", "D", "M")
    Arabe = Array(1, 5, 10, 50, 100, 500, 1000)
    For i = 0 To 6
        If L = Romain(i) Then
            ValueLetters = Arabe(i)
            Exit Function
        End If
    Next i
End Function

Private Sub Command1_Click()
Label2.Caption = "The Decimal Equivalent of " & Text1.Text & " is " & ConvertToDecimal(Text1.Text) & "."
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label2.Caption = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub