CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Need some advice !!!

  1. #1
    Join Date
    Sep 2019
    Saudi Arabia

    Unhappy Need some advice !!!

    First off, I am a beginner in VB 2017 programming.

    I have a small program, consisting of 5 different forms.
    each form has variables (declared with Public Shared ) var1, var2,var3,var4 as String and c1,c2 as Boolean and so on.
    at the last form, I am populating all the variable together ( like FrmMain.var1 = Fvar1, Frm2.var2 = Fvar2 …….)
    now I have an access 2016 Database with the fields specified on the last form ( Fvar1, Fvar2 ………)

    --------- here is the code -----------

    Public Class FrmAdd

    Public Shared xx As Integer
    Public Shared custName, Custnum, CGender, pkind, pmodel, xp As String
    Public Shared byear, curyear, cusage, phauser As Integer
    Public Shared lb250, lb500, lb1000, lb2000, lb4000, la250, la500, la1000, la2000, la4000, la8000 As Integer
    Public Shared hlsince As Decimal
    Public Shared calcsinceold, calcround As Decimal
    Public Shared probear, meduse, tint, tinl, oprobhis, cneed, remark1 As String
    Public Shared c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18 As Integer
    Public Shared lp1, lp2, lp3, lp4, rp1, rp2, rp3, rp4, gp1, gp2, gp3 As Integer
    Public Shared crema As String
    Public Shared e1, e2, e3, e4 As Integer
    Public Shared rb250, rb500, rb1000, rb2000, rb4000, ra250, ra500, ra1000, ra2000, ra4000, ra8000 As Integer
    Public Shared newregionrow As audiologyDataSet.audiodatRow

    Private Sub FrmAdd_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ' here i load the values to be inserted into the database from all the form
    custName = FrmCust.custName
    Custnum = FrmCust.CustnumTextBox.Text
    byear = FrmCust.byear
    CGender = FrmCust.cgender
    phauser = FrmCust.phauser
    pkind = FrmCust.pkind
    pmodel = FrmCust.pmodel
    lb250 = FrmCust.lb250
    lb500 = FrmCust.lb500
    lb1000 = FrmCust.lb1000
    lb2000 = FrmCust.lb2000
    lb4000 = FrmCust.lb4000
    la250 = FrmCust.la250
    la500 = FrmCust.la500
    la1000 = FrmCust.la1000
    la2000 = FrmCust.la2000
    la4000 = FrmCust.la4000
    la8000 = FrmCust.la8000
    rb250 = FrmCust.rb250
    rb500 = FrmCust.rb500
    rb1000 = FrmCust.rb1000
    rb2000 = FrmCust.rb2000
    rb4000 = FrmCust.rb4000
    ra250 = FrmCust.ra250
    ra500 = FrmCust.ra500
    ra1000 = FrmCust.ra1000
    ra2000 = FrmCust.ra2000
    ra4000 = FrmCust.ra4000
    ra8000 = FrmCust.ra8000
    hlsince = Frmhistory.hlsince
    probear = Frmhistory.probear
    c1 = Frmhistory.c1
    c2 = Frmhistory.c2
    c3 = Frmhistory.c3
    c4 = Frmhistory.c4
    c5 = Frmhistory.c5
    c6 = Frmhistory.c6
    c7 = Frmhistory.c7
    c8 = Frmhistory.c8
    c9 = Frmhistory.c9
    c10 = Frmhistory.c10
    c11 = Frmhistory.c11
    c12 = Frmhistory.c12
    c13 = Frmhistory.c13
    c14 = Frmhistory.c14
    c15 = Frmhistory.c15
    c16 = Frmhistory.c16
    c17 = Frmhistory.c17
    c18 = Frmhistory.c18
    meduse = Frmhistory.meduse
    tint = Frmhistory.tint
    tinl = Frmhistory.tinl
    oprobhis = Frmhistory.oprobhis
    lp1 = FrmClinic.lp1
    lp2 = FrmClinic.lp2
    lp3 = FrmClinic.lp3
    lp4 = FrmClinic.lp4
    rp4 = FrmClinic.rp4
    rp3 = FrmClinic.rp3
    rp2 = FrmClinic.rp2
    rp1 = FrmClinic.rp1
    gp1 = FrmClinic.gp1
    gp2 = FrmClinic.gp2
    gp3 = FrmClinic.gp3
    crema = FrmClinic.crema
    e1 = Frmexpect.e1
    e2 = Frmexpect.e2
    e3 = Frmexpect.e3
    e4 = Frmexpect.e4
    cneed = Frmsolution.cneed
    remark1 = " "

    ' here i go to the last position in the datbase and add 1 to get the next availabel record number

    AllCust.AudiodatBindingSource.Position = xp
    xx = Val(xp) + 1

    ' here i add the records

    newregionrow = AllCust.AudiologyDataSet.audiodat.NewaudiodatRow()
    newregionrow.ID = xx

    ' confirm data is saved

    MsgBox("Data Saved")


    End Sub

    End Class
    ---------------------------end code -------------------------

    it is creating a new record, but all the fields are empty.
    also, it is only in memory, when I exit and check the database, nothing was added.

    What am I doing wrong????
    Last edited by EmMit; September 23rd, 2019 at 03:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)