Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have nearly finished my program and I am now looking over it to clean up any rubbish and trying to make things runs a little quicker.

 

I have a few global variables that hold options for the program. These options are read in when the program launches.

 

Would it be better to only read the options in when they are required or to keep it the way i have it.

 

I guess having global variables will use more memory than if I didn't have them.

 

The second part of my quiestion is this. I have a few functions in a module to retrieve the ID of a person in the databse. I would like to turn this into a class but am a little unsure on how to do it.

 

This is what I have in the module.

 

Function GetNameID(ByVal fname As String, ByVal lname As String)
   Dim nameid As Integer

   If fname = "NULL" Or lname = "NULL" Then
     Return 0
   End If

   Dim sql As String = "SELECT ID, Surname, Firstname FROM Contacts " & _ 
      "WHERE Surname = '" & lname & "' AND Firstname = '" & fname & "'"
   Dim objDsName = New DataSet()
   Dim objDaName = New OleDbDataAdapter(sql, cnstring)
   objDaName.Fill(objDsName, "TempName")

   For Each objrow In objDsName.tables(0).rows
     nameid = objrow("ID")
   Next

   objDsName.dispose()
   objDaName.dispose()

   Return nameid

 End Function

Now how would i implement this into a class.

 

Thanks for any help or advice

 

Steve

  • *Experts*
Posted
Instead of putting your global variables and functions in a module you could put all of those in a class and make those variables and methods shared. This means that they do not need an instance of a class to be used.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...