Posts

Showing posts with the label Program

Binary Conversion VB.Net Program

Public Class Form1 Dim a As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a As Integer a = CInt(TextBox1.Text) If a = 0 Then TextBox2.Text = Binary() End If End Sub Function Binary() As String Dim cbin As Integer Dim result As String = "" Dim remainder As Integer cbin = Convert.ToInt32(TextBox1.Text) a = 0 If cbin 0 Then While cbin 0 remainder = cbin Mod 2 If remainder = 1 Then a += 1 End If result = CStr(remainder) & result cbin = cbin \ 2 End While Else result = cbin End If Return result End Function Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox3.T...

Action listener program in Java programming

import java.awt.*; import javax.swing.*; import java.awt.event.*; public class window extends JFrame implements ActionListener{ JTextArea t1= new JTextArea("default text",2,25); JTextArea t2=new JTextArea(2,25); JButton b=new JButton("Copy"); public window(){ super ("Hello World"); setSize(400,200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); Container c=getContentPane(); c.setBackground(Color.black); c.setLayout(new FlowLayout()); b.addActionListener(this); c.add(b); c.add(t1); c.add(t2); setContentPane(c); } public void actionPerformed(ActionEvent event){ t2.setText(t1.getText()); } public static void main(String args[]){ window w=new window(); } }