Selectionchanging is an event on a tab control which is triggered, according to PowerBuilder help, ‘when another tab is about to be selected.’ From this description you might think that this means changing from one tab to another; this is only partially correct. This event is triggered also when the window opens. Depending upon your…
You are currently browsing the Programming category
PowerBuilder ‘Gotcha’ – Selectionchanging event on Tab controls
Calculate the Last Day of the Month
Here is how to calculate the last day of the current month. Powerbuilder date ld_eom ld_eom = RelativeDate(Date(String(Month(Today()) + 1) + "/1/" + String(Year(Today()))), -1) SQL Server SELECT DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, Getdate()) +1, 0)) I quess SQL Denali has a new function (EOMONTH) to do this too. SELECT EOMONTH(GETDATE())
Joining to a Table Function in SQL Server
Following up on my previous post, SQL Server (since version 2005 while in SQL 90 compatibility mode) provides the ability to join to the table created by a parameterized table function. In earlier versions you were not able to use a table function with a dynamic parameter or even join to it. If you needed…
Splitting up a String or Text in SQL
Here is a way to split up a block of text and return a result set based on a delimeter. A table function is used to do the ‘heavy lifting’ and, utilizing some newer features of SQL Server (2005 and 2008), you can even join to it providing for even greater flexability. This situation I…
PowerBuilder ‘Gotcha’ – PixelsToUnits
From the Powerbuilder Help on this method: Converts pixels to PowerBuilder units. Because pixels are not usually square, you also specify whether you are converting the pixels’ horizontal or vertical measurement. Syntax PixelsToUnits ( pixels, type ) Argument Description pixels An integer whose value is the number of pixels you want to convert to PowerBuilder…
PowerBuilder – Reading Outlook Items
Here is some code which reads data from Outlook (2007 was tested) into PowerBuilder. You basically need to create a window with a multiline edit and a button on it. Put this into the clicked event of the button. To run it, open Outlook, select something (email message, task, etc.) then click the button on…
PowerBuilder – Grid datawindow object with variable number of columns
Here is a way to build a grid datawindow which contains columns corresponding to an unknown number of data elements. You could use this approach in creating a project schedule, inventory location system, baseball box score, or any number of other examples. My example assumes the minimum number of columns to be four. This create…
PowerBuilder – Selecting and scrolling to an entry in a Listview control
The listview control in PB lacks the capability to scroll to a highlighted item within the native Powerscript. Here is an easy way to do this by simulating key strokes. First declare the following API subroutine. keybd_event( int bVk, int bScan, int dwFlags, int dwExtraInfo) Library "user32.dll" Next create a user event in the listview…
VBA – Processing ICS calendar file attachments
This article brings to conclusion the Outlook VBA macro/script I wrote to process event scheduling attachments (.ICS or ICalendar files). The first article shows how to process emails and remove their associated attachments. The second shows how to open the files and both read the file contents into an array as well as write (append)…
VBA – Reading a file into an array and Appending to a file
Both of these routines can be called from Outlook Macros/Scripts to process files. In my case I am using them to open iCalendar (ICS) files and place the contents into a string array. The calling method then processes the information then flags the file as ‘PROCESSED’ by the second routine. Public Sub icsFileToArray(ByVal FileName As…