C O D I N G

Click on each heading to display the information.

Below you will find examples of various programs I have created over the years. Currently the programs shown are only written in Java or Visual Basic .NET, but additions will be made over time to include examples from other programming languages. Each programming example includes a picture of the GUI or any viewable output, and a piece of code from the program. Currently I am familiar with Assembly Language, COBOL, C++, CSS, HTML, Java, Javascript MySQL, PERL and VB.NET.




    Private Sub mh_HideIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mh_HideIt.Click
        'do not proceed if a public key has not been calculated
        If mh_H1.Text = "" Or mh_H2.Text = "" _
        Or mh_H3.Text = "" Or mh_H4.Text = "" Then
            MessageBox.Show("A public key must be calculated to proceed", "Decryption Haulted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            makePubK.Focus()
            Exit Sub
        End If

        Dim holdBinaryStr As String
        Dim holdFirst As String
        Dim holdSecond As String
        Dim holdThird As String
        Dim holdFourth As String
        Dim c1, c2, c3, c4 As String

        'hold values are assigned equal pieces of the 16 bit
        'binary string (plaintext)
        holdFirst = mh_PlainTxt.Text.ToCharArray(0, 4)
        holdSecond = mh_PlainTxt.Text.ToCharArray(4, 4)
        holdThird = mh_PlainTxt.Text.ToCharArray(8, 4)
        holdFourth = mh_PlainTxt.Text.ToCharArray(12, 4)

        'cipher values are calculated using the first rowadder
        c1 = rowAdder1(holdFirst, holdFirst.Length)
        c2 = rowAdder1(holdSecond, holdSecond.Length)
        c3 = rowAdder1(holdThird, holdThird.Length)
        c4 = rowAdder1(holdFourth, holdFourth.Length)

        'cipher values are assigned to their respective textboxes
        mh_C1.Text = c1
        mh_C2.Text = c2
        mh_C3.Text = c3
        mh_C4.Text = c4

        'upon completion the encrypt button is locked again
        mh_HideIt.Enabled = False
    End Sub

    Private Sub mh_FindIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mh_FindIt.Click
        'do not proceed if the public key values are not calculated
        If mh_H1.Text = "" Or mh_H2.Text = "" _
        Or mh_H3.Text = "" Or mh_H4.Text = "" Then
            MessageBox.Show("A public key must be calculated to proceed", "Decryption Haulted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            makePubK.Focus()
            Exit Sub
        End If

        Dim t1, t2, t3, t4 As Integer
        Dim c1 As Integer = Integer.Parse(mh_C1.Text)
        Dim c2 As Integer = Integer.Parse(mh_C2.Text)
        Dim c3 As Integer = Integer.Parse(mh_C3.Text)
        Dim c4 As Integer = Integer.Parse(mh_C4.Text)
        Dim modulus As Integer = mh_Mod.Value
        Dim multiplier As Integer = mh_Mult.Value
        'determine the number to calculate target values using findInverse
        Dim number As Integer = findInverse()
        Dim holdFirst As String
        Dim holdSecond As String
        Dim holdThird As String
        Dim holdFourth As String

        'determine the target sums based on the cipher value multiplied
        'by the number(inverse) and mod it by the modulus
        t1 = (c1 * number) Mod modulus
        t2 = (c2 * number) Mod modulus
        t3 = (c3 * number) Mod modulus
        t4 = (c4 * number) Mod modulus


        'determine the binary equivalents of the target sums
        'based on the values of the private key
        holdFirst = binaryTSum(t1)
        holdSecond = binaryTSum(t2)
        holdThird = binaryTSum(t3)
        holdFourth = binaryTSum(t4)

        'assign the strings to the plaintext textbox
        mh_PlainTxt.Text = holdFirst & holdSecond & holdThird & holdFourth

        'lock the decryption button upon completion
        mh_FindIt.Enabled = False
    End Sub
	




   Private Sub rsa_hideIt_Click(ByVal sender As System.Object, ByVal f As System.EventArgs) Handles rsa_hideIt.Click
        'check for calculation of priv and pub keys
        If rsa_Confirm = False Then
            MessageBox.Show("Must find Private and Public Key to encrypt", "Execution error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If

        Dim P As Integer
        Dim C As Integer

        'check if plain is numeric
        Try
            P = Integer.Parse(rsa_plainTxt.Text)
        Catch ex As Exception When IsNumeric(rsa_plainTxt.Text) = False
            MessageBox.Show("Plaintext must be a numeric value", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

        Dim E As Integer = Integer.Parse(rsa_E.Text)
        Dim N As Integer = Integer.Parse(rsa_N.Text)

        'calculate cipher
        C = (P ^ E) Mod N

        rsa_cipherTxt.Text = C.ToString

        'disable the encrypt button
        'disable the plain textbox
        rsa_hideIt.Enabled = False
        rsa_plainTxt.ReadOnly = True
    End Sub

    Private Sub rsa_findIt_Click(ByVal sender As System.Object, ByVal f As System.EventArgs) Handles rsa_findIt.Click
        'Make sure calculations were performed for pub and priv key
        If rsa_Confirm = False Then
            MessageBox.Show("Must find Private and Public Key to decrypt", "Execution error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If

        Dim C As Integer
        Dim P As Integer

        'Check to see that cipher is a numeric
        Try
            C = Integer.Parse(rsa_cipherTxt.Text)
        Catch ex As Exception When IsNumeric(rsa_cipherTxt.Text) = False
            MessageBox.Show("Ciphertext must be a numeric value", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

        Dim D As Integer = Integer.Parse(rsa_D.Text)
        Dim N As Integer = Integer.Parse(rsa_N.Text)

        'Calculate the plain
        P = (C ^ D) Mod N

        rsa_plainTxt.Text = P.ToString

        'disable the decrypt button
        'disable the cipher textbox
        rsa_findIt.Enabled = False
        rsa_cipherTxt.ReadOnly = True
    End Sub
	




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

        Dim startup As New StreamReader("guides\instructions.txt")
        Dim line As String

        Do Until startup.Peek = -1

            line = startup.ReadLine()

            instructions.Text += line & ControlChars.NewLine
        Loop

        startup.Close()

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        instructions.Clear()

        Dim startup As New StreamReader("guides\instructions.txt")
        Dim line As String

        Do Until startup.Peek = -1

            line = startup.ReadLine()

            instructions.Text += line & ControlChars.NewLine
        Loop

        startup.Close()


        Me.Hide()
        main_prog.Show()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        instructions.Clear()

        instructions.ReadOnly = True
        instructions.Enabled = True

        Dim caesar As New StreamReader("guides\CaesarCipher.txt")
        Dim line As String

        Do Until caesar.Peek = -1

            line = caesar.ReadLine()

            instructions.Text += line & ControlChars.NewLine
        Loop

        caesar.Close()
    End Sub
	




public void stateChanged (ChangeEvent e) {

	Graphics paper = drawPanel.getGraphics();
	paper.setColor(Color.white);
	paper.fillRect(0,0,300,300);

	int x,y,size;


	x = xSlider.getValue();
	y = ySlider.getValue();
	size = dSlider.getValue();

	xText.setText(Integer.toString(xSlider.getValue()));
	yText.setText(Integer.toString(ySlider.getValue()));
	dText.setText(Integer.toString(dSlider.getValue()));

	paper.setColor(Color.white);
	paper.fillRect(0,0,300,300);
	paper.setColor(Color.black);
	paper.fillOval(xp1, yp1,5,5);
	paper.fillOval(xp2, yp2,5,5);
	paper.fillOval(xp3, yp3,5,5);

	paper.drawOval(x,y,size,size);


	if( ((x < xMax-20) && (x > xMin+20)) && ((y < yMax-20) && (y > yMin+20)) ){
		JOptionPane.showMessageDialog(null, "You Win!");
		System.exit(0);
	}

}


private int getRandomNum (int min, int max) {

	return min+random.nextInt(max-min+1);
}
	



public void actionPerformed (ActionEvent event){
	Boolean leave = false;

	int size = 0;
	double sum = 0;
	double average = 0;
	int smallest = 0;
	int largest = 0;

	while(leave == false){

		size = Integer.parseInt(JOptionPane.showInputDialog("How many integers?:"));

		if(size >= 0 && size <= 20){
			leave = true;
		}
		else{
			JOptionPane.showMessageDialog(null, "Number must be between 0 and 20");
			leave = false;
		}
	}

	sizeTxt.setText(Integer.toString(size));

	int []numbers = new int[size];

	int count = 0;

	while(count < size){

		numbers[count] = Integer.parseInt(JOptionPane.showInputDialog("Enter a number between 0 and 100:"));

		if(numbers[count] >= 0 && numbers[count] <= 100){
			sum += numbers[count];
			count ++;
		}
		else{
			JOptionPane.showMessageDialog(null, "Number must be between 0 and 100");
		}
	}

	average = sum / size;
	average *= 100;
	average = Math.round(average);
	average = average / 100;

	sumTxt.setText(Double.toString(sum));
	meanTxt.setText(Double.toString(average));

	smallest = findSmall(numbers, size);
	smallTxt.setText(Integer.toString(smallest));

	largest = findLarge(numbers, size);
	largeTxt.setText(Integer.toString(largest));

	int rg1 = 0, rg2 = 0, rg3 = 0, rg4 =0, rg5 = 0, rg6 = 0, rg7 = 0, rg8 = 0, rg9 = 0, rg10 = 0;

	rg1 = rangeCount(numbers, size, 0, 9);
	rg2 = rangeCount(numbers, size, 10, 19);
	rg3 = rangeCount(numbers, size, 20, 29);
	rg4 = rangeCount(numbers, size, 30, 39);
	rg5 = rangeCount(numbers, size, 40, 49);
	rg6 = rangeCount(numbers, size, 50, 59);
	rg7 = rangeCount(numbers, size, 60, 69);
	rg8 = rangeCount(numbers, size, 70, 79);
	rg9 = rangeCount(numbers, size, 80, 89);
	rg10 = rangeCount(numbers, size, 90, 100);




	Graphics paper = graph.getGraphics();
	paper.setColor(Color.black);
	paper.fillRect(0,5,rg1,10);
	paper.fillRect(0,27,rg2,10);
	paper.fillRect(0,47,rg3,10);
	paper.fillRect(0,69,rg4,10);
	paper.fillRect(0,91,rg5,10);
	paper.fillRect(0,113,rg6,10);
	paper.fillRect(0,135,rg7,10);
	paper.fillRect(0,155,rg8,10);
	paper.fillRect(0,175,rg9,10);
	paper.fillRect(0,195,rg10,10);
}
	



public void actionPerformed (ActionEvent event){
	int []numbers = new int[4];
	int []level = new int[4];
	String []sentence = new String[4];
	display.setTabSize(4);
	display.setText("");

	for(int n = 0; n < 4; n++){
		sentence[n] = JOptionPane.showInputDialog("Enter a word:");
		numbers[n] = n;
		level[n] = n;
	}


	int size = 4;
	int iterations = factorial(size)/size;
	int moves = 0;
	int swapChk = 1;
	int swapChkFR = 1;
	int pos = 1;


	showIt(numbers, sentence);


	for(int i=0; i < size; i++){

		numbers[0] = level[0];
		numbers[1] = level[1];
		numbers[2] = level[2];
		numbers[3] = level[3];

		while(moves < 5){

			if(swapChk == 1){
				numbers = swapOnce(numbers);
				showIt(numbers, sentence);
				swapChk = 2;
				moves++;
			}
			else{
				if(swapChkFR == 1){
					numbers = swapTwiceF(numbers);
					showIt(numbers, sentence);
					swapChk = 1;
					swapChkFR = 2;
					moves++;
				}
				else{
					numbers = swapTwiceR(numbers);
					showIt(numbers, sentence);
					swapChk = 1;
					swapChkFR = 1;
					moves++;
				}
			}
		}

		level = getNext(level, pos);
		pos += 1;
		showIt(level, sentence);
		swapChkFR = 1;

		moves = 0;


	}

	pos = 1;
}
	



private void numCheck(String number){

	if(resultTxt.getText() == "0"){
		resultTxt.setText(number);
	}
	else
		resultTxt.setText(resultTxt.getText() + number);
}


private void decCheck(){
	if(on == false){
		resultTxt.setText(resultTxt.getText() + ".");

		on = true;
	}
	else
		JOptionPane.showMessageDialog(null, "Only one decimal point allowed!");
}


private void changeNP(){
	double temp;

	temp =  (Double.parseDouble(resultTxt.getText())) * -1;

	resultTxt.setText(Double.toString(temp));
}


private void addIt(){

	operatorID = 1;

	on = false;

	x = Double.parseDouble(resultTxt.getText());

	resultTxt.setText("0");
}


private void subIt(){

	operatorID = 2;

	on = false;

	x = Double.parseDouble(resultTxt.getText());

	resultTxt.setText("0");
}


private void multIt(){

	operatorID = 3;

	on = false;

	x = Double.parseDouble(resultTxt.getText());

	resultTxt.setText("0");
}


private void divIt(){

	operatorID = 4;

	on = false;

	x = Double.parseDouble(resultTxt.getText());

	resultTxt.setText("0");
}


private void solveIt(){

	double result = 0;

	y = Double.parseDouble(resultTxt.getText());

	switch(operatorID){

		case 1:
			result = x + y;
			break;
		case 2:
			result = x - y;
			break;
		case 3:
			result = x * y;
			break;
		case 4:
			result = x / y;
			break;

		default:
			result = 0;
			break;
	}

	on = false;

	result = result * 10;
	result = Math.round(result);
	result = result/10;

	resultTxt.setText(Double.toString(result));
}


private void clearIt(){

	x = 0;
	y = 0;
	operatorID = 0;

	resultTxt.setText("0");
}
	



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If rVal.Text = "" Or gVal.Text = "" Or bVal.Text = "" _
        Or (IsNumeric(rVal.Text) = False Or IsNumeric(gVal.Text) = False _
        Or IsNumeric(bVal.Text) = False) Then

            MessageBox.Show("Cannot proceed unless R, G, and B contain numeric values, between 0 and 255", "Error with conversion", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            rVal.Clear()
            gVal.Clear()
            bVal.Clear()
            rVal.Focus()
        Else
            If ((Integer.Parse(rVal.Text) > 255 Or Integer.Parse(rVal.Text) < 0) _
            Or (Integer.Parse(gVal.Text) > 255 Or Integer.Parse(gVal.Text) < 0) _
            Or (Integer.Parse(bVal.Text) > 255 Or Integer.Parse(bVal.Text) < 0)) Then
                MessageBox.Show("Cannot proceed unless R, G, and B contain numeric values, between 0 and 255", "Error with conversion", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                rVal.Clear()
                gVal.Clear()
                bVal.Clear()
                rVal.Focus()
            End If

            Dim r, g, b As String
            r = Hex(Short.Parse(rVal.Text))
            g = Hex(Short.Parse(gVal.Text))
            b = Hex(Short.Parse(bVal.Text))

            If r.Length < 2 Then
                r = "0" & r
            End If

            If g.Length < 2 Then
                g = "0" & g
            End If

            If b.Length < 2 Then
                b = "0" & b
            End If


            hexVal.Text = r & g & b
            hexVal.Text = hexVal.Text.ToUpper
            End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        hexVal.Text = hexVal.Text.ToUpper

        If hexVal.Text > "FFFFFF" Then
            MessageBox.Show("Hex values cannot exceed the letter 'F'", "Error attempting conversion", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            hexVal.Clear()
            hexVal.Focus()

        Else

            If hexVal.TextLength < 6 Then
                MessageBox.Show("Hex value must be at least 6 characters, therefore the entry will be padded with zeros on the left", "Entry length error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

                If hexVal.TextLength = 1 Then
                    hexVal.Text = "00000" & hexVal.Text
                ElseIf hexVal.TextLength = 2 Then
                    hexVal.Text = "0000" & hexVal.Text
                ElseIf hexVal.TextLength = 3 Then
                    hexVal.Text = "000" & hexVal.Text
                ElseIf hexVal.TextLength = 4 Then
                    hexVal.Text = "00" & hexVal.Text
                Else
                    hexVal.Text = "0" & hexVal.Text
                End If

            End If

            Dim r, g, b As String

            r = hexVal.Text.ToCharArray(0, 2)
            g = hexVal.Text.ToCharArray(2, 2)
            b = hexVal.Text.ToCharArray(4, 2)

            rVal.Text = Convert.ToInt32(r, 16)
            gVal.Text = Convert.ToInt32(g, 16)
            bVal.Text = Convert.ToInt32(b, 16)
        End If
    End Sub