How to deal with the brackets?

argument , vba , array India
  • 11 years ago

    Yesterday i was trying to pass an array as an argument to a function. I tried that for half an hour or so, trying to pass it like any other variables using brackets but my friend adviced not to use brackets when pass arrays. To my wonder it worked. Thats why i wants to know what are all the things we must aware of when dealing with brackets.

  • 11 years ago

    Public Sub Test() CreateNewWriterDoc() InsertPicture("C:\Jitender.jpg") SetSize(GetGraphicObject(0), 1000, 1000) End Sub Public Sub SetSize(ByVal MyObject As Object, ByVal Height As Long, ByVal Width As Long) Dim MySize As New Object MySize = CreateUnoStruct("") MySize.Height = Height MySize.Width = Width MyObject.setSize(MySize) End Sub Public Function GetGraphicObject(ByVal Key As Object) As Object If VarType(Key) = VariantType.String Then 'GetGraphicObject by name GetGraphicObject = GetGraphicObjects.getByName(Key) ElseIf VarType(Key) = VariantType.Integer Then 'GetGraphicObject by index GetGraphicObject = GetGraphicObjects.getByIndex(Key) Else GetGraphicObject = Nothing End If End Function Public Function GetGraphicObjects() As Object '1) First step to work with GraphicObjects: 'get the GraphicObjects collection GetGraphicObjects = ThisComponent.getGraphicObjects End Function Public Function InsertPicture(ByVal Filepath As String) As Object 'Instanciate a frame for the graphic object InsertPicture = ThisComponent.createInstance("") 'get image InsertPicture.GraphicURL = ConvertToURL(Filepath) 'insert the image ThisComponentText.InsertTextContent(TextCursor, InsertPicture, False) End Function Public Sub GotoBookmark(ByVal Name As String) '2) second step: 'Find Bookmarkbyname Dim CurseurPos As Object 'Find cursor posiution here on bookmark anchor 'Find anchor of the bookmarks CurseurPos = GetBookmark(Name).Getanchor 'Move visible cursor to text cursor ViewCursor.GoToRange(CurseurPos, False) End Sub Public Function GetBookmark(ByVal Name As String) As Object 'Check if Bookmark exists If GetBookmarks.HasByName(Name) = True Then 'Find Bookmarkbyname GetBookmark = GetBookmarks.GetByName(Name) Else GetBookmark = Nothing End If End Function Public Function GetBookmarks() As Object '1) First step to work with bookmarks: 'get the bookmarks collection GetBookmarks = ThisComponent.getBookmarks End Function Public Function CreateNewCalcDoc() As Object Dim arg(-1) As Object 'Create a new Calc doc CreateNewCalcDoc = StarDesktop.LoadComponentFromUrl("private:factory/scalc", "blank", 0, arg) End Function Public Function CreateNewWriterDoc() As Object Dim arg(-1) As Object 'Create a new Writer doc CreateNewWriterDoc = StarDesktop.LoadComponentFromUrl("private:factory/swriter", "blank", 0, arg) End Function Public Function TextCursor() As Object '1 'Method to find create a textcursor TextCursor = ViewCursorText.CreateTextCursor '2 Move the textcursor to the ViewCursor TextCursor.GotoRange(ViewCursor, False) End Function Public Function ThisComponentText() As Object 'Method to get TextRange of the CurrentComponent ThisComponentText = ThisComponent.GetText End Function Public Function ObjetXCurrentController() As Object 'Method to find the CurrentController ObjetXCurrentController = ThisComponent.getCurrentController End Function Public Function ViewCursorText() As Object 'Method to get TextRange of the ViewCursor ViewCursorText = ViewCursor.GetText End Function Public Function ViewCursor() As Object '*Method to find the view cursor ViewCursor = ObjetXCurrentController.GetViewCursor End Function Public Function ConvertToURL(ByVal Filepath As String) As String 'Change windows notation to OO Dim Newstring As String Newstring = Replace$(Filepath, "\", "/") ConvertToURL = ("file:///" & Newstring) End Function Public Function CreateUnoStruct(ByVal Service As String) As Object 'Equivalent to oOOBasic Function CreateUnoStruct = GetProcessServiceManager.Bridge_GetStruct(Service) End Function Public Function CreateUnoService(ByVal Service As String) As Object 'Equivalent to oOOBasic Function CreateUnoService = GetProcessServiceManager.CreateInstance(Service) End Function Public Function ThisComponent() As Object 'Equivalent to oOOBasic Function ThisComponent = StarDesktop.getCurrentComponent End Function Public Function StarDesktop() As Object 'Equivalent to oOOBasic Function StarDesktop = CreateUnoService("") End Function Public Function GetProcessServiceManager() As Object 'Equivalent to oOOBasic Function GetProcessServiceManager = CreateObject("") End Function

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann