none
How do i convert the VB.net code to VBA...

    Question

  •  

    Hi.

    I am trying to Read jpg file into file stream which is VB.net and i want it in VBA.. The below code is in VB.Net

     

    Code Snippet

    'Read jpg into file stream, and from there into Byte array.

    Dim fsBLOBFile As New FileStream(strBLOBFilePath, FileMode.Open, FileAccess.Read)

    Dim bytBLOBData As Byte() = New Byte(fsBLOBFile.Length - 1) {}

    fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length)

    fsBLOBFile.Close()

     

     

     

    I have tried to write the above code in VBA

     

    Code Snippet

    Dim fsBLOBFile As System.Io.FileStream
    fsBLOBFile = System.Io.File.Open(Pict, FileMode.Open, FileAccess.Read)

    Dim br As System.Io.BinaryReader
    br = System.IO.BinaryReader(fsBLOBFile.Length)
    Dim bytBlobFile() As Byte
    byblobFile = br.ReadBytes(fsBLOBFile.Lenght)

    br.Close
    fsBLOBFile.Close

     

     

    But when i run my code i get the an error that Compiler error User-Defined type not defined..

    and it points to Dim fsBLOBFile As System.Io.FileStream

    any help will be appreciated..

     

    Thanks.

    Karen

     

     

    Tuesday, December 02, 2008 4:41 PM

Answers

  • I have never seen a convertor from .net to VBA although there is convertors from say VB to C++ and others.  VBA takes some real hands on to learn, as a beginner (still) I find it somewhat difficult, it is only a hobby for me so I dont get much hands on doing real programming, I do use it for some excel macros but my stuff is not really difficult.

    Someone will be along soon to just do the work for you, are you the type to spend time in MSDN much, there is a wealth of info and training in there.
    Wednesday, December 03, 2008 4:51 AM

All replies

  • I have never seen a convertor from .net to VBA although there is convertors from say VB to C++ and others.  VBA takes some real hands on to learn, as a beginner (still) I find it somewhat difficult, it is only a hobby for me so I dont get much hands on doing real programming, I do use it for some excel macros but my stuff is not really difficult.

    Someone will be along soon to just do the work for you, are you the type to spend time in MSDN much, there is a wealth of info and training in there.
    Wednesday, December 03, 2008 4:51 AM
  • Yeah i do like msdn... esp the forums.. I am VBA newbie too...They have a wealth of info and training too

    Wednesday, December 03, 2008 1:58 PM