AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Stephen Jackson
Expertise
I can help with questions regarding VB.NET syntax and object references, with data interfaces and with the design and creation of robust, data aware object classes. I can also be very helpful with creating distributable applications and provide tricks and tips on .msi creation. I also have extensive experience in designing SQL Server Databases and interfacing them with VB.NET. I try to avoid web specific questions, as that is an area of expertise all its own.

Experience

Experience in the Area:
I have been a programmer in Visual Basic since version 1.0 and have worked with VB.NET (which is infinitely more powerful than previous versions) since its initial release and SQL Server, both as a corporate IT professional and professional consultant. I first wrote Basic in 1976 on a TRS 80 and have worked in Visual Basic 1.0 and every subsequent release of Microsoft Visual Basic. I worked for over 7 years as a Senior Level Consultant in the area and currently hold a Project Manager position in IT.

Education and Credentials:
MBA in Econometrics, 1983, University of Memphis. BBA in Financial Management, 1982, Fogelman College of Business and Economics, University of Memphis.
Microsoft Certified Professional

Areas of Special Expertise:
My specialty is the design of Object Oriented Solutions with robust, data aware object classes. I generally avoid the classic ‘Three Tier’ model as I find it redundant and cumbersome to maintain. I also specialize in the creation of ‘User Friendly’ User Interfaces which help lessen the need for user training and help prevent user error. I work best with Windows Forms based applications, and while I do work in C# as well, I prefer to limit my questions here to Windows Forms based applications created in Visual Basic.NET and SQL Server. I wil also address questions relating to the distribution and installation of Windows Forms based applications created in VB.NET.
 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > posted regarding "next", "previous" and "save"

Topic: VB.NET



Expert: Stephen Jackson
Date: 2/8/2008
Subject: posted regarding "next", "previous" and "save"

Question
hi,

i came upon your site and saw how you were able to help this programmer. i have a similar question to that.
you see im making a program that allows me to input, updatea and change records.

in my code for "next" and "previous" which i copied from another site, the program tells me that i have a identifier expected.

you can see that in sub button 1 and 2. if i take out the underscore, another error comes out. could you please help me here?

also, i have been able to databind my 08 vb.net with sql. why is it when it tells me to save it is unable to do so?

i appreciate the comments that you will be giving to finally make this program operational.

thank you.

Public Class frm4

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNMAIN.Click
       Dim frmselect As New frm3()
       Me.Close()
       frmselect.Show()
   End Sub

   Private Sub BTNCLEAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCLEAR.Click
       txtmonth.Text = ""
       txtemp.Text = ""
       txtname.Text = ""
       txtdays.Text = ""
       txtrate.Text = ""
       TXTMED.Text = ""
       txtbasic.Text = ""
       txtsss.Text = ""
       txtibig.Text = ""
       txttax.Text = ""
       txtded.Text = ""
       txtnet.Text = ""
   End Sub

   Private Sub BTNCOMPUTE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCOMPUTE.Click
       Dim nw, rd, md, bs, ss, pi, t, d, np As Double

       nw = Val(txtdays.Text)
       rd = Val(txtrate.Text)
       rd = 270
       txtrate.Text = rd

       bs = Val(TXTBASIC.Text)
       bs = nw * rd
       TXTBASIC.Text = bs

       ss = Val(txtsss.Text)
       ss = bs * 0.02
       txtsss.Text = ss

       md = Val(TXTMED.Text)
       md = 120
       TXTMED.Text = md

       pi = Val(TXTIBIG.Text)
       pi = 100
       TXTIBIG.Text = 100

       t = Val(TXTTAX.Text)
       t = bs * 0.035
       TXTTAX.Text = t

       d = Val(txtded.Text)
       d = ss + md + pi + t

       txtded.Text = d

       np = bs - d
       TXTNET.Text = np

   End Sub

   Private Sub BTNSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSAVE.Click
       Dim SaveFileDialog1 As SaveFileDialog = New System.Windows.Forms.SaveFileDialog

       With SaveFileDialog1
           .DefaultExt = ".mdb"
           .Filter = "access database|*.mdb"
           .InitialDirectory = "desktop"
       End With

       If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
           Console.WriteLine(SaveFileDialog1.FileName)
       End If
   End Sub

   Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnload.Click
       OleDbDataAdapter1.Fill(DataSet31)
   End Sub

   Private Sub BTNREMOVEITEM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
       Me.BindingContext(DataSet31, "table1").EndCurrentEdit()
       Me.OleDbDataAdapter1.Update(DataSet31)
   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprevious.Click
       Me.BindingContext(DataSet31, "table1").Position = Me.BindingContext(DataSet31, _"table1").Position - 1

   End Sub

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       Me.BindingContext(DataSet31, "table1").Position = Me.BindingContext(DataSet31, _"table1").Position + 1

   End Sub
End Class


Answer
William,

I just happened to catch this before I go to bed so let me see if I can help.  If I understand correctly, the code for buttons 1 and 2 will not compile, missing an identifier.  I notice there might be an inconsistency with the reference code in that copied code.  

Instead of  

Private Sub Button1_Click( _
     ByVal sender As System.Object, ByVal e As System.EventArgs)
      Handles btnprevious.Click

      Me.BindingContext(DataSet31, "table1").Position = _
            Me.BindingContext(DataSet31, _"table1").Position - 1

  End Sub

Try this:

Private Sub Button1_Click( _
     ByVal sender As System.Object, ByVal e As System.EventArgs)
      Handles btnprevious.Click

      Me.BindingContext(DataSet31, "table1").Position = _
            Me.BindingContext(DataSet31, "table1").Position - 1

  End Sub

That should take you to the previous (or next) record ... if you are not at the beginning (end) of the recordset! Of course make sure the actual event handlers are properly pointing to the buttons, too. The underscore was probably a line break in the original code.  Since I do not understand exactly how your data link is set up, I am unable to diagnose the properties beyond examining the consistency of the code.

For the other try:

Private Sub Button2_Click( _
     ByVal sender As System.Object, ByVal e As System.EventArgs)
      Handles Button2.Click

      Me.BindingContext(DataSet31, "table1").Position = _
            Me.BindingContext(DataSet31, "table1").Position + 1

  End Sub

Please let me know if this does not work and I will do my best to help!  Also, if this works, please be kind enough to leave me some feedback .. this is my first question!

Thanks,

Stephen Jackson  

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.