Feb 25, 2014

Math library in Java ME

Math.round() is not available in J2ME.
So, it's hard to round a double.

Jan 15, 2014

VB Script

I've needed to access an Access file from an html file. I did could do this using VBScript. It is running very well with Internet Explorer and could be a solutions in Corporatist offices wher security level is too paranoic.

Now I'm working with vbscripts. I use it to generate local xml files. Those xml files I use  to keep data from Access files to be easier to read in my network. The answer of my small app (.hta file) is much faster then if I read straight from MS Access file.

So, I used following code to generate a new .xml file:

<script type='text/vbscript'> 
        Set oFS = CreateObject("Scripting.FileSystemObject") 
           Const strXmlFile = "Documents.xml" 
           Set objXMLFile = oFS.OpenTextFile(strXmlFile, 2, True, 0) 
            objXMLFile.WriteLine "" 
            objXMLFile.WriteLine ""'" href=""Documents.xsl""?>" 
            objXMLFile.WriteLine "
           'Set myFolder = oFS.GetFolder("Documents") 
            'For Each File In myFolder.Files 
            'FileLast = File.DateLastModified 
            'FileMod = DateDiff("d", FileLast, Now) 
            '    If FileMod < 5 Then 
             'Corporate = File.Name 
             'myDate = Split(FileLast,"/") 
             'myYear = Left(myDate(2),4) 
             'myMonth = myDate(0) 
             'myURL = "Whatever your URL is" 
             'Download = "Wherever your download site is" 
             'Call CreateXML(Corporate,myYear,myMonth,myURL,Download) 
             Call CreateXML("Corporatia","myYear","myMonth","myURL","Download") 
              
                'End If 
            'Next 
           'This next call will run once the "CreateXML" has finished. 
           Call CloseXML() 
           Function CreateXML(Corporate,myYear,myMonth,myURL,Download) 
            objXMLFile.WriteLine vbTab & "
            objXMLFile.WriteLine vbTab & vbTab & "" & Corporate & "
            objXMLFile.WriteLine vbTab & vbTab & "" & myYear & "
            objXMLFile.WriteLine vbTab & vbTab & "" & myMonth & "
            objXMLFile.WriteLine vbTab & vbTab & "" & myURL & "
            objXMLFile.WriteLine vbTab & vbTab & "" & Download & "
            objXMLFile.WriteLine vbTab & "
           End Function 
           Function CloseXML() 
            objXMLFile.WriteLine "
"              wscript.echo "Completed XML Creation" 
           End Function 

          </script>

VBA Excel - Syntax for "for"

Syntax for "for":


For i = 4 To 2000 
    ' do something                
Next i 

MS Access - open form in another database

If you want to open a new form from another Access file you can use following code:

Public Sub OpenForeignForm()  
 Dim appAccess As Access.Application  
 Set appAccess = CreateObject("Access.Application")  
 appAccess.OpenCurrentDatabase "C:\MyPath\DataBaseName2.mdb"  
 appAccess.DoCmd.OpenForm "FormName"  
 Set appAccess = Nothing 
End Sub