Wednesday, December 7

Disable editing in combobox control in VB.Net

This is a very simple tutorial yet it's very helpful. We use combobox to dispaly an editable list of text/string but what if we do not want or allow our user to edit the items in a combobox? what we want is to select from list of choices. This codes will disallowing our user to modify or edit the text/string in our combobox control.

First drop a combobox control in the form and name it. Go to the code and declare a boolean variable and set it to false:




Public Class Form1
Dim editingInCombobox As Boolean = False


then create keypress event in the combobox control (creating event in vbnet code window).



Once you done, add the following line of codes in the keypress block:


If Not editingInCombobox Then e.Handled = True

Beep()



editingInCombobox = is the boolean variable we declared
Beep ( ) = Sounds a tone through the computer's speaker.

That's it, I hope you like it.



15 That ye may be blameless and harmless, the sons of God, without rebuke, in the midst of a crooked and perverse nation, among whom ye shine as lights in the world;


Philipians 2:15 KJV


Praise to LORD JESUS CHRIST


Creating event in VB.Net Code window

Basically, we create an event by double clicking the control or write it manually, this is what we always do. This post is one way to create an event is our controls.

STEPS:
Drop the control to the designer then rename the control (renaming control is a good practice when we do programming).
This example is using button control

 After we created and renamed the control go to the code window and select the control (btnEvent) from the class name

 

Then select the event or method in the Method name list. The list contains all of the posible event you can use in a control

That's it, type the codes and do the logic inside the block. I hope it helped you.


The LORD is my rock, and my fortress, and my deliverer; my God, my strength, in whom I will trust; my buckler, and the horn of my salvation, and my high tower. I will call upon the LORD, who is worthy to be praised: so shall I be saved from mine enemies. 

Psalm 18:2-3



Praise the LORD

Saturday, November 12

Displaying total value of a column in SQL

Im going to show how to display total value of your data in the database. This script will works on integer datatype (Im not sure if it work in currency or money datatype but Maybe it will work).

The SQL syntax is:

SELECT  ISNULL(Column1, 'TheLastWord') AS ALIAS, Column2      
FROM (
      SELECT Column1,
             GROUP_FUNCTION(Column1) AS Column1,
             GROUP_FUNCTION(Column2) AS Column2
      FROM TABLE
          GROUP BY Column1 WITH ROLLUP
     ) AS ALIAS



Example:

SELECT ISNULL(Sales_MONTHS, 'TOTAL SALES in 2011') AS MONTH
   TRANSACTION ,      
   SALES
    
FROM (
      SELECT Sales_MONTHS,
             SUM(TRANSACTION ) AS TRANSACTION ,
             SUM(SALES) AS SALES
           
      FROM SALES_TABLE
          GROUP BY Sales_MONTHS WITH ROLLUP
     ) AS BI






Note that this script or systax works in MS SQL. Other database may have different syntax.
Thats it, I hope this simple tutorial would helped.





3 Then Jesus told them this parable: 4 “Suppose one of you has a hundred sheep and loses one of them. Doesn’t he leave the ninety-nine in the open country and go after the lost sheep until he finds it? 5 And when he finds it, he joyfully puts it on his shoulders 6 and goes home. Then he calls his friends and neighbors together and says, ‘Rejoice with me; I have found my lost sheep.’ 7 I tell you that in the same way there will be more rejoicing in heaven over one sinner who repents than over ninety-nine righteous persons who do not need to repent.

Luke 15:3-7(NIV)

To God all the Glory!