Convert  vb6.0 to 2.0 syntax

Posted on 2009-07-01
Last Modified: 2012-05-07
Can anybody suggest on converting the function from vb6.0 to 2.0

Public Function GetCodes(formid As String) As Boolean

Dim SQL As String

Dim RsCodes As Recordset

Dim rsCodesTable As Recordset

Dim clause As String


'identify if the formid has any codes associated with it.


SQL = "Select tag,ctrltype from Controls where " & ctUcase & "(formid) = " & UCase(GetSQLValue(formid, ctText)) & _

" AND " & ctUcase & "(Ctrltype) <> " & GetSQLValue("LABEL", ctText)

Set RsCodes = OpenRs(SQL, SysDB)

If RsCodes.EOF Or RsCodes.BOF Then

    'no controls associated with this form


    'make a in statement of all fieldnames

    Do Until RsCodes.EOF

        clause = clause & UCase(GetSQLValue(RsCodes!Tag, ctText)) & ", "



End If

If clause <> Empty Then

    clause = UCase(" IN (" & Left(clause, Len(clause) - 2) & ")")

End If


If clause <> "" Then

    SQL = "Select Count(*) as Tot FROM Codes WHERE " & ctUcase & "(fieldname) " & clause

    Set rsCodesTable = OpenRs(SQL, MemDB)

    If rsCodesTable!Tot = 0 Then

        GetCodes = False


        GetCodes = True

    End If


    If GetCodes = True Then

        'if codes exist then exit sub

        Exit Function

    End If

End If


'Secondly - find out if the formid have any links to the codes table


SQL = "Select Count(*) as Tot from Controls where formid = " & GetSQLValue(formid, ctText) & " and linktable = 'CODES'"

Set RsCodes = OpenRs(SQL, SysDB)

If RsCodes!Tot = 0 Then

    GetCodes = False


    GetCodes = True

End If


Set RsCodes = Nothing

Set rsCodesTable = Nothing

End Function

Open in new window

Question by:RIAS
1 Comment
LVL 15

Accepted Solution

mohan_sekar earned 500 total points
ID: 24754469
Use SQLDataReader for RecordSet and SQLConnection for Connection.

For Do until RsCodes.EOF, use

While reader.Read()
...your stuff
End While

Reset of them should be straightforward.

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now