Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to call function that return object

how to call function that return object

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    hi iam new vb learner, i got a problem how to call function that return object it always said object variable not set but i think i already call it as object, is that in my code how to call object something wrong ? -------------------------------------------- Public Function accessinfo() As Object Dim myFSO, f As Object Dim filename As String On Error GoTo errhandler filename = fillist.Path + "\" + fillist.filename Set myFSO = CreateObject("Scripting.FileSystemObject") Set f = myFSO.GetFile(filename) txt_datecreated.Text = f.DateCreated txt_dateaccess.Text = f.DateLastAccessed txt_datemodified.Text = f.DateLastModified txt_size.Text = (Format((f.Size / 1024) / 1, "##")) + " kilobyte " Exit Function accessinfo = f errhandler: MsgBox "No File selected !. Please select the file ", vbCritical, Warning End Function ------------------------------------------------------- and then i want to call function accessinfo in getinfo Private Sub cmd_getinfo_Click() Dim fso As Object Set fso = accessinfo MsgBox (fso.DateCreated) End Sub

    N D T 3 Replies Last reply
    0
    • A Arif Liminto

      hi iam new vb learner, i got a problem how to call function that return object it always said object variable not set but i think i already call it as object, is that in my code how to call object something wrong ? -------------------------------------------- Public Function accessinfo() As Object Dim myFSO, f As Object Dim filename As String On Error GoTo errhandler filename = fillist.Path + "\" + fillist.filename Set myFSO = CreateObject("Scripting.FileSystemObject") Set f = myFSO.GetFile(filename) txt_datecreated.Text = f.DateCreated txt_dateaccess.Text = f.DateLastAccessed txt_datemodified.Text = f.DateLastModified txt_size.Text = (Format((f.Size / 1024) / 1, "##")) + " kilobyte " Exit Function accessinfo = f errhandler: MsgBox "No File selected !. Please select the file ", vbCritical, Warning End Function ------------------------------------------------------- and then i want to call function accessinfo in getinfo Private Sub cmd_getinfo_Click() Dim fso As Object Set fso = accessinfo MsgBox (fso.DateCreated) End Sub

      N Offline
      N Offline
      Naji El Kotob
      wrote on last edited by
      #2

      Hi, You are using a Late Binding Technique, try to use the IO.File Class instead, Check this link http://msdn2.microsoft.com/en-us/library/system.io.file.getcreationtime.aspx[^] and the list of File members for extra samples http://msdn2.microsoft.com/en-us/library/system.io.file_members.aspx[^] Hope this helps :)

      NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...

      1 Reply Last reply
      0
      • A Arif Liminto

        hi iam new vb learner, i got a problem how to call function that return object it always said object variable not set but i think i already call it as object, is that in my code how to call object something wrong ? -------------------------------------------- Public Function accessinfo() As Object Dim myFSO, f As Object Dim filename As String On Error GoTo errhandler filename = fillist.Path + "\" + fillist.filename Set myFSO = CreateObject("Scripting.FileSystemObject") Set f = myFSO.GetFile(filename) txt_datecreated.Text = f.DateCreated txt_dateaccess.Text = f.DateLastAccessed txt_datemodified.Text = f.DateLastModified txt_size.Text = (Format((f.Size / 1024) / 1, "##")) + " kilobyte " Exit Function accessinfo = f errhandler: MsgBox "No File selected !. Please select the file ", vbCritical, Warning End Function ------------------------------------------------------- and then i want to call function accessinfo in getinfo Private Sub cmd_getinfo_Click() Dim fso As Object Set fso = accessinfo MsgBox (fso.DateCreated) End Sub

        D Offline
        D Offline
        Dominick Marciano
        wrote on last edited by
        #3

        I may be wrong in this but you have 'Exit Function' before 'accessinfo=f' to the function is trying to return to its caller before the object has been set. Why not try removing the 'Exit Function' and the 'accessinfo=f' and just replace it with 'Return f'?

        1 Reply Last reply
        0
        • A Arif Liminto

          hi iam new vb learner, i got a problem how to call function that return object it always said object variable not set but i think i already call it as object, is that in my code how to call object something wrong ? -------------------------------------------- Public Function accessinfo() As Object Dim myFSO, f As Object Dim filename As String On Error GoTo errhandler filename = fillist.Path + "\" + fillist.filename Set myFSO = CreateObject("Scripting.FileSystemObject") Set f = myFSO.GetFile(filename) txt_datecreated.Text = f.DateCreated txt_dateaccess.Text = f.DateLastAccessed txt_datemodified.Text = f.DateLastModified txt_size.Text = (Format((f.Size / 1024) / 1, "##")) + " kilobyte " Exit Function accessinfo = f errhandler: MsgBox "No File selected !. Please select the file ", vbCritical, Warning End Function ------------------------------------------------------- and then i want to call function accessinfo in getinfo Private Sub cmd_getinfo_Click() Dim fso As Object Set fso = accessinfo MsgBox (fso.DateCreated) End Sub

          T Offline
          T Offline
          TomGarth
          wrote on last edited by
          #4

          Your Exit Function is preventing the "accessinfo = f" assignment from executing. Once you fix that, you will have to add "Set" to the object assignment. - "Set accessinfo = f".

          Tom Garth Developer R. L. Nelson and Associates, Inc., Virginia

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups