Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Apr 2008
    Gender
    Male
    Posts
    351

    Default vb6 code for copying field1 to field 2 with in the same table


    Patabang ta ko sa mga master. bag-o pako sugod ug programming using vb6.

    naa koy table named TABLE1 with field1(nvarchar) field2(float)

    these are the records below:

    field1
    12-56
    54-58
    45-58
    45-52
    ...and more

    gusto nko i convert ang first 2 ug ang last 2 characters into numbers sa field1 ug ang resulta sa computation isulod nko sa field2

    mao ni akong codes:

    Private Sub cmdConvert_Click()

    On Error Resume Next
    a=datagrid1.columns("field1")
    a1 = Val(Left(a, 2))
    a2 = Val(Right(a, 2))
    a3 = la1 + (a2 / 300)

    OpenConn
    Set rstemporary = OpenRst("UPDATE TABLE1 set field2='" & a3 & "'")
    datConvert.Recordset.Update
    datConvert.RecordSource = "select * from TABLE1"
    datConvert.Refresh

    Endsub

    naay resulta pero ang masulod kay usa raman ka records sa field1


    mangayo ko sa inyong tabang mga master1

  2. #2
    Junior Member
    Join Date
    Apr 2008
    Gender
    Male
    Posts
    351

    Default Re: vb6 code for copying field1 to field 2 with in the same table

    wa pa guro kabasa ang mga master ani or wala pa sad nakasugat ani?

  3. #3

    Default Re: vb6 code for copying field1 to field 2 with in the same table

    gamit og loop brad. usa ra gyud na ang record kay ang 1st line/row ra man sa imo table ang ipaprocess sa imo code. dili ko master ha, pero try lang ko og tabang nimo.

    First, kuhaa ang rowcount sa imong table, mao na ang gamiton nimo na limit(upper boundary sa imong loop). Dayon sulod sa loop mag set currentrow ka(dili lang ko sure kung mo-work ni kung directly sa query result nimo). Kay usually, ang query result nako nakasave man sa temporary file(datatable sa QTP or Excel file)

    getrowCount = datagrid1.getrowcount
    for counter = 1 to getrowCount
    datagrid1.setcurrentrow(counter)
    [your code here]
    Next

    amateur tabang ra sad ni ang akoa, commonly used man gud ni nako sa qtp. Pero mas maayo gyud ang tambag sa mga masters.

  4. #4

    Default Re: vb6 code for copying field1 to field 2 with in the same table

    kung gusto ka ma.update tanang records sa imong table,
    Mao ni ang steps.
    1st. Loop all your records
    2nd. Within your loop, put statement to convert what you desire to convert.
    3rd. Within your loop also, execute an update statement to update each records with their desired data.

    Same mi ug concept ni sakagawasan pero ang iyaha is i.select ang total number of counts.

    ang akoa kay loop ra sa imong table.

    end point is, same ra mi ug idea.

  5.    Advertisement

Similar Threads

 
  1. Looking for a lawyer to consult with
    By kni38 in forum Business, Finance & Economics Discussions
    Replies: 26
    Last Post: 11-20-2022, 08:37 PM
  2. Looking For: for a room to rent with CR 5k near lahug budget
    By FNDR in forum Real Estate
    Replies: 0
    Last Post: 09-01-2011, 02:41 PM
  3. Replies: 21
    Last Post: 04-19-2009, 06:58 AM
  4. Relationships with-in the same company
    By mastercarfinder in forum Career Center
    Replies: 44
    Last Post: 10-17-2008, 04:37 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
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top