Wednesday, 1 August 2012

How to Show Power Point Slide Show in Visual Basic

There are many way to show a power point slide show in vb form one can use OLE or a frame window
I'm showing it in a separate window. to show presentation do following steps

Make some declaration in general section 

  • Public oPPTApp As Object          
  • Public oPPTPres As Object
  • Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
          (ByVal lpClassName As String, _
           ByVal lpWindowName As Long) As Long
  • Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Function for show presentation

Private Sub slideShow() 
    Dim screenClasshWnd As Long
    Set oPPTApp = CreateObject("PowerPoint.Application")
    If Not oPPTApp Is Nothing Then
            Set oPPTPres = oPPTApp.Presentations.Open("Paste Your Presentation file path", , , False)
         If Not oPPTPres Is Nothing Then
             With oPPTPres                  
                          With .SlideShowSettings
                                 .ShowType = 1000
                                 .Run
                        End With
                Call SetWindowText(FindWindow("screenClass", 0&), APP_NAME)
        
        End With
       Else
        MsgBox "Error : Could not open the presentation.", vbCritical, APP_NAME
    End If
Else
    MsgBox "Could not instantiate PowerPoint.", vbCritical, APP_NAME
End If
End Sub

 

     

Monday, 30 July 2012

How to get input in character type array in java

Hi ............
There are many way to get input in java. Java works on two type of stream 1. Character Stream 2. Byte Stream
Java treats Char data type different form c and c++. In C/C++ char data type hold 7 bit ASCII Character which is 0 to 127 characters but java char data type works on Unicode.
  • System.in.read() takes one character from user and return correspondence int value
  • for hold it we have to type cast in char
  • System.in.read() stop when user press enter its take it '\n'
class CharInput
{
           public static void main(String args[]) throws Exception
           {
                  char ar[]=new char[5];
                  int i;
                  for(i=0;i<ar.length;i++)
                  {
                          ar[i]=getChar();
                   }
            }
            static char getChar() throws Exception
            {
                   char ch=(char) System.in.read();
                   pressEnter();
                   return ch;
             }
             static void pressEnter() throws Exception
             {
                    while((char) System.in.read()!='\n');
              }
}  
  • As we know System.in.read() stop input when it encounter newline
  • i have make getChar function which is taking input from user and sure newline using pressEnter function
  • pressEnter is use to ensure newline character using while loop
  • loop stop when user press enter otherwise it looking in stream for new line

Wednesday, 4 July 2012

Add Controls Run time in VB.NET & C#


hi............
Mostly we make control design time, we handle many event like click, mouseover,moueout etc. This is a easy process for design time because there is not any need to attach event handler visual studio attach necessary code automatically.
You can add control on run time………… for do this you will have to perform following steps
  • Make an object of relevant control
    eg. Button btn =new Button()      [C# ]
          dim btn as new Button()         [VB.NET]
  • After make an object of control you have to manage control property
    eg. Location,size,backcolor,text etc
  • You can also attach events..
Add an Button in C#
  Button btn = new Button();
            btn.Text="Click";
            btn.Location=new Point(100,100);
            btn.Click +=new EventHandler(btn_Click);
            this.Controls.Add(btn);
     following function will catch and handle button click event….
private void btn_Click(object sender,EventArgs e)
        {
            MessageBox.Show("Called");
        }
Add a combo box in vb.net
            Dim com As ComboBox
        com = New ComboBox
        com.Items.Add("one")
        com.Items.Add("two")
        com.Items.Add("three")
        com.Location = New Point(150, 100)
        AddHandler com.SelectedIndexChanged,AddressOf com_click
        Me.Controls.Add(com)
following function will catch and handle combo box
selectindexchange event….
       Private Sub com_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox("Called event")
    End Sub
       

Monday, 2 July 2012

How to Retrieve records from ms access using date field in condition

Hi...... there
As you know SQL is a language which enable us to use database. If you've knowledge of SQL then you can operate any database software, for achieve this you just need to know how to run SQL Statement in that DBMS package
One thing you must know that there are some different in SQL in different DBMS package they use different data type and size, they treat date field as different way so if you want to use SQL you must know what are the SQL specification for that DBMS package
Develop Raj Kumar
Form of project
  • MS Access treat date field differently from SQL server
  • If you want to make a condition based on date you'll have to put date between ## e.g #7/28/2010
  • Import System.Data.OleDb name space for oledb class

     

     

     

    Save Button Code

    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=your path")
            Try
                con.Open()
                Dim dd As String
                dd = DateTimePicker1.Value.Date
                Dim com As New OleDbCommand()
                com.Connection = con
                com.CommandText = "insert into stu values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & dd & "')"
                com.ExecuteNonQuery()
                MsgBox("Saved")
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

    Search Button Code

     Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your Path")
            Dim da As New OleDbDataAdapter("select * from stu where dob=#" & DateTimePicker1.Value.Date & "#", con)
            Dim ds As New DataSet
            da.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)