Input validation etc

Discussion in 'Software' started by Black_Bean, Dec 22, 2008.

  1. Black_Bean

    Black_Bean Private E-2

    Hi People,

    I was wondering if anybody could help me with the following VB problem?

    1st) I have a calculator process and I need to validate the input. Know I have done a catch and try for checking if the input is numeric or not. But is there a simple way to check if the input in the calculator is plus or minus numbers.

    I want to prevent minus numbers form being inputed.

    2nd) I am trying to access two different tables with in one database. I have set up a form where that table can be displayed, but it is trying to look up the wrong table and I dont know how to get it too look up the other table.

    The following is the code that I have to acess the database and bring the information from the tables into memory:-

    Code:
    Dim dt As New DataTable
        ' create and object called dt of the class datatable
        Dim rowindex As Integer     ' create an integer to hold which row of the table we are at
        ' Create a string with the appropriate connection details ie data provider and data source
        Dim connStr As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source = EngineerJobs.mdb"
        ' create a string containing a valide SQL statement that will return data
        Dim sqlStr As String = "SELECT * FROM Engineers_Allocated, Engineers"
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '
            
            'Opens a connection to a database and extracts data from it
            '
            'empty datatable for refilling
            
            dt.Clear()
    
            'Create a link to the database via a datatadapter
            Dim DataAdapter As New OleDb.OleDbDataAdapter(sqlstr, connStr)
            'fill the datatable created with the contents of the dataAdaptor
            DataAdapter.Fill(dt)
            'Destroy the dataAdaptor - saves memory etc
            DataAdapter.Dispose()
            'move one records details to the textboxes - as rowindex is initially zero this is the first record
    
    Is there a different way to get information from the database and put it into the form?

    For the form I have the next record and previous record buttons which relate to the following code:-
    Code:
    Sub UpdateTextboxes2()
            '
            
            'Updates the textboxes on the form with data held in the row indicated by the rowindex variable
    
            
            Dim Fieldno As Integer = 0
    
    
            'Move the contents of record into the fields 
            TxtJobID.Text = CStr(dt.Rows(rowindex)(0))  'by position
            txtengineer.Text = CStr(dt.Rows(rowindex)("EngineerNO")) 'by name
            txtjob.Text = CStr(dt.Rows(rowindex)(2))
    If anybody can help me with this I would be very thankfull as this is all to do with an Assignment for Uni that needs to be in, in the new year.

    Cheers in advance peop's!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds