Tuesday, September 29, 2009

Relevance of Business process in software development

During college days, we are required to make a project in every subject, in programming subject we still need a documentation. My hatest part is writing about business background because I don't know what to write. When I start working as a programmer, first thing I did is to interview some accountants so I will know their process and how they do it in operation. I recorded the interview on my mp3 player then listened to it when I'm back at my desk (what a programmer knows about banking and corporate finance, bonds, shares, coupons etc???). With that, I have written a lot of descriptions, specification and technical documentation that helped understand the process, how they do their work even if it is beyond my expertise and helped me solved the problem. Having a business process study also contributes to the existing software (which is poorly documented by the maker) that I developed and made it easier for me whenever they want to add something or there changes in their business process.

Be Object oriented

When I am just starting to be a programmer, the way how I code is very procedural. Because as a begginer, I thought procedural is the simplest way and you can solve problems even not being an object oriented type of coder. Until I start working in a bank where I met complicated problems and still code the procedural way. I applied the way I code in C language which is a procedural language to a language that can create GUI. Eventually, I decided to learn a new language as my new skill, C++, an object oriented programming language. As I am studying C++, the book explained the true meaning of OOP that changed my mind and convinced me to make my project in object oriented way. At first I don't know exactly what is the difference between procedural and OOP, well, procedural has limitations while in OOP, you can create your own. This explanation really changed my way how I code: To solve a complicated problem, simulate the process by creating objects. For example, a radio composed of different parts or objects. You need to code for speaker, capacitor, antenna, tuner etc. to build a radio. You can download a capacitor which could be coded by others and adopt its functions and put it to your radio project to make it work. You can make objects in OOP just like what we have in real world. This way helped me solved complicated problems and make my application perform faster.

Wednesday, June 24, 2009

Visual Basic 6 Classes

Hello,
When I was new in VB 6, using Class looks alien to me and seems hard to do. But then I realized that making class is very very convenient for you even in the future projects. I started using classes this year. I suggest you to google about visual basic classes, buy a book, or search this PDF: Basic Introduction to classes written by Mike D Sutton of Edais. This is where I started and reading C++ book also adds knowledge about classes/class programming. Using Classes can reduce developing/coding time for future use or future projects. Using class also make your program easy to maintain. You can add class to your visual basic project by: in your visual basic 6.0 IDE menu bar(along with File, Edit etc..), click Project, then click Add Class Module. Note: Using Module is different from Class Module. If you want to program professionaly in VB 6, learn proper using of classes, this could be your first step and advancement.

Happy 1st Anniversary

Hi, It's been a year since I started this blog. I felt sorry that I haven't post many of my solutions that I have done with my projects because of my hectic schedule as a programmer. But all of that is written and I'll post that eventually. Some of tips that I got regarding rare problems and solutions are in http://www.experts-exchange.com/. I thank all of the guys there and in http://www.vbforums.com/ where I shared some solutions for the first time. I encouraged new programmers to be a member of these forums or others and read, read, and read. You can also ask some professional programmers/developers, It will help you a lot. Shalom!

Monday, March 9, 2009

Run-Time error '-2147217887 (8004Je21)'

Multiple-step OLE DB operation generated errors. i encountered this error when uploading data from excel file straight to mssql database using ADODB. this is my simple solution: in my insert statement, i commented columns one by one and test insert query one at a time. until i reached the numeric data which will be uploaded to a numeric column, this is where run-time occurs. now i checked the columns in table and noticed that size of column is only numeric(10,2), so that i tried to changed it to numeric(14,2). Then run the test and all works fine, simple problem is solved.

Friday, February 13, 2009

Retrieving fields in mysql using php

I experienced this problem when im retrieving data in mysql database. It is my 1st time to use select statement in php. I've read in some tutorial in the net that, mysql_fetch_array() can retrieve your data from database. But now i used this --> @mysql_fetch_array(); and it worked. I am using php 5 and the newest mysql version. This is my code:

if the code below gives you some error, try my 2nd code

$result = mysql_query("SELECT * FROM customer WHERE c_id = '$id'");
if(!$result)
{
die(mysql_error());
}
while($row = mysql_fetch_array($result))
{
echo $row['c_id'];
echo $row['c_comment'];
echo $row['c_name'];
}

At the end, this is my 2nd code:

$result = mysql_query("SELECT * FROM customer WHERE c_id = '$id'");
if(!$result)
{
die(mysql_error());
}
while($row = @mysql_fetch_array($result))
{
echo $row['c_id'];
echo $row['c_comment'];
echo $row['c_name'];
}

Wednesday, October 29, 2008

Using left Join to change specific data

I encountered this problem during work. I accidentally edited a column(acctType) without having a parameter for where condition to specify an item to edit. The result is, all items in interest_table have changed its acctType to 'rt'. Now, all i have to do is to match it with other table. First, i looked for the relationship of the table or something in common with other table. Then i saw transaction_table. In this case, i used a simple update statement with left join. In other acctType, i used the same statement, but changed only 'rt' to necessary acctType.

solution:
UPDATE interest_table SET int_acctType = 'rt' FROM interest_table LEFT JOIN transaction_table on tu_number = int_number where tu_acctType = 'rt'

Moral lesson for this story: don't forget to use WHERE if neccessary

Friday, October 10, 2008

draw the flow


When i was in college, i hate to draw flowcharts. i don't even believe that i can use that. in our school, we have to make projects in every subject. in my documentation there's a part called program design. Every process in our program we have to make a flowchart. When i got a job in an international bank as programmer, i draw pages of flowcharts. Learn to draw flowcharts. But in drawing flowcharts, know first the logic of the program. This will serve as your map in developing programs. This will be your logic flow to achieve your task or algorithm.

Thursday, September 18, 2008

how to split strings in textbox in vb

i encountered this problem during my work. so this is the story:

our client bank is using a different system when uploading the data(accounts) we have extracted from our system. one main problem is the name field. our system uses one textfield for name but their system is using 2 fields for name(firstname and surname). then i used this work around to fit with their system:
1. this one initializes the variables
Dim i As Integer
Dim b As String, c As String, d As String
Dim str2() As String
2. split string in text1 and assign it to array and text2 is ready to use for first name
str2 = Split(Text1, " ", , vbTextCompare)
Text2.Text = str2(0)
3. this assign the length of the string array to i and zero-out text3
i = UBound(str2)
Text3 = ""

4. this routine separates string from spaces
For a = 1 To i
If str2(a) <> "" Then
str2(a) = str2(a)
Else
a = a - 1
End If
Next

5. re-assign the new value of i for use with the next routine.(printing of final strings)
i = UBound(str2)
If i <>i = 1
Else
i = 2
End If
6. this is the last routine, assign the strings collected in textbox
For a = 1 To i
Text3 = Trim(Text3 & " " & str2(a))
Next

hope you learned from this little stuff.

Monday, August 4, 2008

Visual Basic 6 and Crystal Reports 10

I wrote this because I spend 2 weeks solving how to use Crystal 10 with VB because I thought passing parameter in Crystal 8 is the same with Crystal 10. Crystal has many new features but I still prefer using Crystal 8 for ease of use.
In this tutorial, add 1 form to your project, add 1 button and two textbox
1. First, go to Project>references: Add Crystal ActiveX Report Viewer Library 10.0 and Crystal Reports ActiveX Designer Run Time Library 10
2. go to Project>Components: then add Crystal ActiveX Report Viewer Library 10
3.add new form to your project then draw the Crystal ActiveX Report Viewer to the form.

4.add this code to the form2:
Private Sub Form2_Resize()
crview.Top = 0
crview.Left = 0
crview.Height = Me.ScaleHeight
crview.Width = Me.ScaleWidth
End Sub
this for the viewers flexibility

5. add this code and put this on top of all (Declarations):
dim appl as New CRAXDRT.Application
dim rep as new CRAXDRT.Report
6. declare these variables in button_click():
Dim name as String, Address as String, ReportFile as String

7. and assign these variables to textboxes also in button_click():
name = Text1.text
Address = Text2.text
ReportFile = App.path & "\report.rpt" 'assuming that you have already designed your report.

8.This is how you pass paramater to your report(also in button_click():
Set rep = appl.OpenReport(ReportFile)
rep.DiscardSavedData
rep.ParameterFields(1).ClearCurrentValueAndRange
rep.ParameterFields(1).AddCurrentValue(name)
rep.ParameterFields(2).ClearCurrentValueAndRange
rep.ParameterFields(2).AddCurrentValue(Address)
Form2.show 'this is the 2nd form with Crystal Viewer

9. Add this code to form 2 Load() event:
crview.ReportSource = rep
crview.EnableExportButton = True
crview.Refresh
crview.ViewReport

Hope this tutorial gives you a lot idea about using crystal reports 10 and be able to use this with MS SQL or access,etc..