• All
  • Free Web Hosting
  • Category 2

Archives

gravatar

Kevern Solutions: Limmiting File Types to be Uploaded in PHP?

Kevern Solutions: Limmiting File Types to be Uploaded in PHP?: "<script type='text/javascript'> function Checkfiles() { var fup = document.getElementById('uploaded_file'); var uploaded_file = fup.v..."

gravatar

Limmiting File Types to be Uploaded in PHP?


<script type="text/javascript">
function Checkfiles()
{
var fup = document.getElementById('uploaded_file');
var uploaded_file = fup.value;
var ext = uploaded_file.substring(uploaded_file.lastIndexOf('.') + 1);
if(ext == "doc" || ext == "JPG" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "pdf" || ext == "bmp" || ext == "BMP" || ext =="zip" || ext == "rar")
{
return true;
}
else
{
alert("Ooops! the file you are trying to upload is not supported!, Please upload only the supported file format.");
//fup.focus();
//return false;
document.getElementById('uploaded_file').value = "";
}
}
</script>

gravatar

Kevern Solutions: Checking two the same values in a Combo Box in Java...

Kevern Solutions: Checkin two the same values in a Combo Box in Java...: "The main purpose of this script is to determine that the values selected is already selected on the first selection, Let say we have created..."

gravatar

Checkin two the same values in a Combo Box in Javascript.

The main purpose of this script is to determine that the values selected is already selected on the first selection, Let say we have created a Two Combo Box that load data from MySql Database. (Auto Populate)

The Code:

function CheckSameData(){
if (document.getElementById('FirstSelection').value == document.getElementById('SecondSelection').value){
alert ("Selection is Already been Selected.");
document.getElementById('SecondSelection').focus();
document.getElementById('SecondSelection').style.color = '#FF0000'; //This will change the font color of the duplicating item.
return false;
}
return true;
}

gravatar

How to validate empty values in an array?

if (dml.elements[i].name=='Names[]')// Immediate Name
                {
               
                  // if exists do the validation and set the focus to the textbox
                     if (dml.elements[i].value=="")
                    {
                        alert("Your Name is Required!");
                        dml.elements[i].focus();
                        return false;           
                    }
                }

gravatar

Kevern Solutions: Show and Hide Text Box in Javascript.

Kevern Solutions: Show and Hide Text Box in Javascript.: "Show and hide a textbox by simply using this code. Fully compatible to all browsers. Thanks to the original author of this script. Insert t..."

gravatar

Show and Hide Text Box in Javascript.

Show and hide a textbox by simply using this code. Fully compatible to all browsers. Thanks to the original author of this script.

Insert this script in your <HEAD>.
<script type="text/javascript">
function doClick2(objRad3){
if (objRad3.value=="0"){
document.getElementById("textbox3").style.display='none'; //hide textbox
document.getElementById("otherOpt3").style.display='block'; //show other options
document.getElementById('CrimeDetails').value = 'N/A'; //this will be the default value upon dumping.
}
else{
document.getElementById("otherOpt3").style.display='none'; //hide other options
document.getElementById("textbox3").style.display='block'; //show textbox
document.getElementById('CrimeDetails').value = 'Please give details.';
}
}
</script>

gravatar

Kevern Solutions: How to detect a browser type in JavascriptV?

Kevern Solutions: How to detect a browser type in JavascriptV?: "I found this very useful script in the internet and I just want to share it's usability. This script can be applied if ever you want your sy..."

gravatar

How to detect a browser type in JavascriptV?

I found this very useful script in the internet and I just want to share it's usability. This script can be applied if ever you want your system to detect and inform the user that he or she is using an Internet Explorer Browser.

The Code:
<!--THIS WILL DETECT INTERNET EXPLORER BROWSERS-->
<script language="JavaScript"
type="text/JavaScript">

 if(navigator.appName == "Microsoft Internet Explorer")
{
 alert("This site works best with Mozilla Firefox.\nThank You!")
close();
}
</script>

Thanks to the Original Author.

gravatar

How to Accept Numeric Characters Only in Javascript?

Create a textbox in your HTML or PHP Program, Then insert this code after the HEAD on your HTML code.

<script language="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
}
</script>

gravatar

Kevern Solutions: Loading the Adobe Reader Plug-in in PHP.

Kevern Solutions: Loading the Adobe Reader Plug-in in PHP.: "<div id='template-template'> <div style='padding:10px;margin-top:50px'> &..."

gravatar

Loading the Adobe Reader Plug-in in PHP.

<div id="template-template">
    <div style="padding:10px;margin-top:50px">
        <object
            data="./files/usersmanual.pdf#toolbar=0"
            type="application/pdf"
            width="100%"
            height="580px">
            <p>Adober Reader plugin is missing. Please install plugin version 9 or higher.</p>
    </object>
    </div>
</div>



Make sure that you have already downloaded the adobe reader for php, you can download it from the internet. Just ask Google.

gravatar

Kevern Solutions: Defining Firefox and IE Browser Response

Kevern Solutions: Defining Firefox and IE Browser Response: " callback : function(options,success,result){ &nbsp..."

gravatar

Defining Firefox and IE Browser Response

 callback : function(options,success,result){
                var response = Ext.util.JSON.decode(result.responseText);

                if(response.success == true){

                    if(Ext.isIE){
                        messageBox(response.message, Ext.MessageBox.INFO);
                    }else{
                        successmessage(response.message);
                    }
                   
                }else{

                    if(Ext.isIE){
                        messageBox(response.errors.reason, Ext.MessageBox.ERROR);
                    }else{
                        errormessage(response.errors.reason);
                    }
                }
            }

gravatar

How to show search items or data in ExtJs

function showSearch(){
    var dataPanel = Ext.getCmp('details-grid');
    Ext.Ajax.on('beforerequest',function(conn,o,result){
        dataPanel.getEl().mask('Loading data...','x-mask-loading');
    })

    Ext.Ajax.on('requestcomplete',function(conn,o,result){
        dataPanel.getEl().unmask(true);
    })

    Ext.Ajax.on('requestexception',function(conn,o,result){
        dataPanel.getEl().unmask(true);
    })
    Ext.Ajax.request({
        url     : 'ajax/items.php',
        method  : 'POST',
        params  : {
        _method : "showitemlist",
        _class  : "itemlist",
        emp        :Ext.getCmp('itemCode').getValue().toUpperCase()
        },
        callback : function(options,success,result){
            var response = Ext.util.JSON.decode(result.responseText);

            if(response.success){

                store = new Ext.data.Store({
                      proxy  : new Ext.ux.data.PagingMemoryProxy(response.data),
                      reader : new Ext.data.ArrayReader({
                      fields : [
//From your Database Table
                         {name:'ITEMCODE'},
                         {name:'ITEMNAME'},
                         {name:'ITEMPRICE'},
                         {name:'ITEMDESC'},
                         {name:'ITEMREMARKS'},
                         {name:'QUANTITY'},
                         {name:'ISAVAILABLE'},
                         {name:'PURDATE'}
                      ]
                    })
                })
                store.loadData(response.data);
                store.load({params:{start:0, limit:14}});
            }else{
                Ext.MessageBox.show({
                    title   : 'e-Purchase',
                    msg     : response.errors.reason,
                    buttons : Ext.MessageBox.OK,
                    icon    : Ext.MessageBox.WARNING,
                    animEl  : document.body
                })
            }
        }
    })
}

gravatar

Removing HTML Editor's Toolbars in ExtJs

 {
                        xtype                       : 'htmleditor',
                        enableLinks             : false,
                        enableLists              : false,
                        enableSourceEdit    : false,
                        enableColors           : true,
                        enableFontSize        : true,
                        enableFormat          : false,
                        id                            : 'message',
                        width                       : 455,
                        height                      : 290,
                        fieldLabel                : 'Message',
}

gravatar

Setting Firebird Database Engine in PHP

<?php

    session_start(); //You can enable error reporting by setting value to 1

    error_reporting(0);

 //echo session_id();

    $_SESSION['currsession'] = session_id();

    if(isset($_SESSION['result_session'])){

        $endsession = $_SESSION['result_session'];

    }

    if($endsession == $_SESSION['currsession']){

        header('location:grades.php');

    }
   
    include_once("DBConnect/constants.php");
    include_once("DBConnect/DBInstance.php");
   
    DBInstance::setDBEngine(DBASE_ENGINE);
    DBInstance::setDBase(YOUR_DATABASE_NAME_HERE);
   
   
    $dbInstance = DBInstance::getInstance();
   
    $trans = ibase_trans(IBASE_DEFAULT,$dbInstance);
   
    $positionList= array();
    //if(isset($_POST["issubmit"])){
        //validation here.
       
        try{
               
                   
            $query = "Your Query Here";
           
            $pstmt = ibase_prepare($trans,$query);
            $result = ibase_execute($pstmt);
            if(!$result){
                throw new Exception(ibase_errmsg(),ibase_errcode());
            }
           
            while($row = ibase_fetch_object($result)){
           
                $positionList[]= array(
                    "position"=>$row->POSITION,
                    "description"=>$row->DESC
                );
            }
        //print_r($positionList);
       
            ibase_commit($trans);
        }catch(Exception $e){
            echo "No data dump to system database, Transaction has been rolled back.";
            echo $e->getMessage();
            ibase_rollback($trans);
           
        }
    //}
   
?>

Note: If you are using Linux Web Server make sure that you have a correct Systax in PHP.

gravatar

Kevern Solutions: Creating Triggers in Firebird Database

Kevern Solutions: Creating Triggers in Firebird Database: "Create a trigger in your database workbench name it 'Data_TrigerCreated' and the code below will automatically create a timestamp into you..."

gravatar

Creating Triggers in Firebird Database

Create a trigger in your database workbench name it "Data_TrigerCreated" and the code below will automatically create a timestamp into your table.
After you have created the trigger, you must name your field as the same what is below:
-CREATEDDATE
-CREATEDBY

The DDL:

/*
  You can change this template in the template editor:
  File | Preferences | Object Templates

  Trigger:

  Author   : KBVILLARUBIA
  Date     : 03/14/2011
  Purpose  :
*/
begin
     NEW.CREATEDDATE = 'NOW';
     NEW.CREATEDBY = user;
end

SAMPLE DATA WILL BE THE FF.:

CREATEDDATE              CREATEDBY
3/15/2011 6:10:59PM        ADMINISTRATOR

gravatar

Kevern Solutions: Graphics

Kevern Solutions: Graphics: "Asus Latest Graphics Adaptor
Enjoy 100% Blu-Ray Quality Audio with HDMI 1.3 Compliance
and Video Enhancement
The Essential Component ..."

gravatar

How to Create Class in Visual Basic 6.0

'#
'@author:Ken V.
'@date: November 13,2009
'@update: -
'@version: Ver 1.0.1
'#
Option Explicit
Private name As Integer
Private age As String
Private address As String


Public Property Let letbatchid(ByVal newbatchid As Integer)
    batchid = newbatchid
End Property
Public Property Get getbatchid() As Integer
    getbatchid = batchid
End Property

Public Property Let letbatchno(ByVal name As String)
    name= newname
End Property

Public Property Get getname() As String
    getname = name
End Property

Public Property Let letage(ByVal newage As String)
    age= newage
End Property

Public Property Get getaddress() As String
    getaddress= address
End Property

//This is just a simple example on how to create class in Visual Basic 6.0.


Enjoy!

gravatar

Kevern Solutions: Upload Data using Microsoft Excel in Visual Basic ...

Kevern Solutions: Upload Data using Microsoft Excel in Visual Basic ...: " Author: Ken V. Option Explicit Dim pricelistObj As PriceListObjectClass Dim xlconn As ADODB.Connection Dim xlrs As ADODB.Recordset..."

gravatar

Kevern Solutions: Using the RowColChange in Visual Basic 6.0 (The Ba...

Kevern Solutions: Using the RowColChange in Visual Basic 6.0 (The Ba...: "Click Image to Enlarge Author: Ken V. Private Sub MSHFlexGrid1_RowColChange() With MSHFlexGrid1 &nbs..."

gravatar

Using the RowColChange in Visual Basic 6.0 (The Basic)

Click Image to Enlarge
Author: Ken V.

Private Sub MSHFlexGrid1_RowColChange()
    With MSHFlexGrid1
       Text1.Text = .TextMatrix(.RowSel, 0)
        Text2.Text = .TextMatrix(.RowSel, 1)
        Text3.Text = .TextMatrix(.RowSel, 2)
        Text4.Text = .TextMatrix(.RowSel, 3)
        Text5.Text = .TextMatrix(.RowSel, 4)
        Text6.Text = .TextMatrix(.RowSel, 5)
        Text7.Text = .TextMatrix(.RowSel, 6)
        Text8.Text = .TextMatrix(.RowSel, 7)
        Text9.value = .TextMatrix(.RowSel, 8)
        Text10.Text = .TextMatrix(.RowSel, 9)
        Text11.Text = Format$(Val(.TextMatrix(.RowSel, 10)), "#0.00")

   End With
End Sub

gravatar

Upload Data using Microsoft Excel in Visual Basic 6.0 (MySql Database)

 Author: Ken V.


Option Explicit

Dim pricelistObj As PriceListObjectClass

Dim xlconn As ADODB.Connection
Dim xlrs As ADODB.Recordset

Dim rs As New Recordset

Dim gridToUpload As MSHFlexGrid

Dim col As Integer
Dim row As Integer

Public Sub initXL(xlApp As String)
    Set xlconn = New ADODB.Connection
    Set xlrs = New ADODB.Recordset
   
    With xlconn
        .Provider = "MSDASQL"
        .connectionString = "Driver={Microsoft Excel Driver (*.xls)};" & _
        "DBQ=" & xlApp & "; ReadOnly=False;"
        On Error GoTo errHandler
        .Open
    End With
   
    Exit Sub
errHandler:
    MsgBox Err.Description
End Sub

Public Sub populateUPLGrid(xlApp As String, grid As MSHFlexGrid)
    initXL (xlApp)
    grid.Clear
   
    With xlrs
        If .State = adStateClosed Then
            .Open "select * from [sheet1$]", xlconn, adOpenKeyset, adLockOptimistic
        End If
       
        Set grid.DataSource = xlrs
    
    End With
   
   
    Set gridToUpload = grid
End Sub
Public Sub updloadData(progress As ProgressBar, cmdUpload As CommandButton)
   
    Dim delay1 As Integer
    Dim delay2 As Integer
      
    progress.value = 0
   
    row = 1
   
    With gridToUpload
        cmdUpload.Enabled = False
        Do While row < .Rows
                //here I upload a list of price list into mysql database using the vb6 interface.
            setValues (row)
            Call RevisedTransModule.addPricelist(pricelistObj)
            For delay1 = 0 To 10000
                For delay2 = 0 To 1000
                Next delay2
            Next delay1
            progress.value = ((row + 1) / gridToUpload.Rows) * 100
           
            row = row + 1
        Loop
        cmdUpload.Enabled = True
    End With
    MsgBox "Data has been successfully uploaded!"
End Sub
Public Sub setValues(rowCount As Integer)
    Dim colName As String

    Set pricelistObj = New PriceListObjectClass

    With gridToUpload
        col = 0
        Do While col < (.Cols)
            colName = Trim(.TextMatrix(0, col))
            Select Case colName
                Case "Data1"
                    pricelistObj.letData1 = .TextMatrix(rowCount, col)
                Case "Data2"
                    pricelistObj.letData2 = .TextMatrix(rowCount, col)
                Case "Data3"
                    pricelistObj.letData3 = .TextMatrix(rowCount, col)
                Case "Data4"
                    pricelistObj.letData4 = .TextMatrix(rowCount, col)
                Case "Data5"
                    pricelistObj.letData5 = .TextMatrix(rowCount, col)
                Case "Data6"
                    pricelistObj.letData6 = .TextMatrix(rowCount, col)
                Case "Data7"
                    If .TextMatrix(rowCount, col) <> "" Then
                        pricelistObj.letData7 = .TextMatrix(rowCount, col)
                    End If
            End Select
            col = col + 1
        Loop
    End With
End Sub

Public Sub fromOjbToGrid(r_index As Integer, grid As MSHFlexGrid)
    Dim colName As String
   
    With grid
        col = 0
        Do While col < (.Cols)
            colName = Trim(.TextMatrix(0, col))
            Select Case colData
                Case "Data1"
                    .TextMatrix(r_index, col) = pricelistObj.getData1
                Case "Data2"
                    .TextMatrix(r_index, col) = pricelistObj.getData2
                Case "Data3"
                    .TextMatrix(r_index, col) = pricelistObj.getData3
                Case "Data4"
                    .TextMatrix(r_index, col) = pricelistObj.getData4
                Case "Data5"
                    .TextMatrix(r_index, col) = pricelistObj.getData5
                Case "Data6"
                    .TextMatrix(r_index, col) = pricelistObj.getData6
                Case "Data7"
                    .TextMatrix(r_index, col) = pricelistObj.getData7
            End Select
            col = col + 1
        Loop
    End With
End Sub
//here I make the Upload history, simple way in checking the uploaded data.
Public Sub checkUploaded(grid As MSHFlexGrid)
    grid.Clear
   
    Dim gridIndex As Integer
   
    gridIndex = 1
   
    grid.Rows = gridToUpload.Rows
    grid.Cols = gridToUpload.Cols
   
    For col = 0 To gridToUpload.Cols - 1
        grid.TextMatrix(0, col) = gridToUpload.TextMatrix(0, col)
    Next
   
   
   
    With gridToUpload
        row = 1
        Do While row < .Rows
            setValues (row)
            On Error Resume Next
            rs.Open "select * from DataTable where Data1='" & pricelistObj.getData1 & "' and Data2='" & pricelistObj.Data2 & "' and Data3='" & pricelistObj.getData3 & "'", conn, adOpenKeyset, adLockOptimistic
           
            If Not rs.EOF Then
                Set pricelistObj = New PriceListObjectClass
                pricelistObj.letData1 = rs!Data1                pricelistObj.letData2 = rs!Data2                pricelistObj.letdata3 = rs!Data3
                pricelistObj.letdata4 = rs!Data4
                pricelistObj.letData5 = rs!Data5
                pricelistObj.letData6 = rs!Data6
                pricelistObj.letData7 = rs!Data7
               
                Call fromOjbToGrid(gridIndex, grid)
                gridIndex = gridIndex + 1
            End If
            rs.Close
            row = row + 1
        Loop
    End With
End Sub

Public Sub checkRejected(grid As MSHFlexGrid)
    grid.Clear
   
    Dim gridIndex As Integer
   
    gridIndex = 1
   
    grid.Rows = gridToUpload.Rows
    grid.Cols = gridToUpload.Cols
   
    For col = 0 To gridToUpload.Cols - 1
        grid.TextMatrix(0, col) = gridToUpload.TextMatrix(0, col)
    Next
   
    With gridToUpload
        row = 1
        Do While row < .Rows
            setValues (row)
            On Error Resume Next
            rs.Open "select * from DataTable where Data1='" & pricelistObj.getData1 & "' and Data2='" & pricelistObj.getData2 & "' and Data3='" & pricelistObj.getData3 & "'", conn, adOpenKeyset, adLockOptimistic
           
            If rs.EOF Then
                Call fromOjbToGrid(gridIndex, grid)
                gridIndex = gridIndex + 1
            End If
            rs.Close
            row = row + 1
        Loop
    End With
End Sub

gravatar

Kevern Solutions: How to Enable Write in .INI File in Visual Basic 6...

Kevern Solutions: How to Enable Write in .INI File in Visual Basic 6...: "Option Explicit Public Function WriteIniValue(INIpath As String, PutKey As String, PutVariable As String, PutValue As String) Dim temp As S..."

gravatar

How to Enable Write in .INI File in Visual Basic 6.0

Option Explicit

Public Function WriteIniValue(INIpath As String, PutKey As String, PutVariable As String, PutValue As String)
Dim temp As String
Dim LcaseTemp As String
Dim ReadKey As String
Dim ReadVariable As String
Dim LOKEY As Integer
Dim HIKEY As Integer
Dim KEYLEN As Integer
Dim VAR As Integer
Dim VARENDOFLINE As Integer
Dim NF As Integer
Dim X As Integer

AssignVariables:
    NF = FreeFile
    ReadKey = vbCrLf & "[" & LCase$(PutKey) & "]" & Chr$(13)
    KEYLEN = Len(ReadKey)
    ReadVariable = Chr$(10) & LCase$(PutVariable) & "="
       
EnsureFileExists:
    Open INIpath For Binary As NF
    Close NF
    SetAttr INIpath, vbArchive
   
LoadFile:
    Open INIpath For Input As NF
    temp = Input$(LOF(NF), NF)
    temp = vbCrLf & temp & "[]"
    Close NF
    LcaseTemp = LCase$(temp)
   
LogicMenu:
    LOKEY = InStr(LcaseTemp, ReadKey)
    If LOKEY = 0 Then GoTo AddKey:
    HIKEY = InStr(LOKEY + KEYLEN, LcaseTemp, "[")
    VAR = InStr(LOKEY, LcaseTemp, ReadVariable)
    If VAR > HIKEY Or VAR < LOKEY Then GoTo AddVariable:
    GoTo RenewVariable:
   
AddKey:
        temp = Left$(temp, Len(temp) - 2)
        temp = temp & vbCrLf & vbCrLf & "[" & PutKey & "]" & vbCrLf & PutVariable & "=" & PutValue
        GoTo TrimFinalString:
       
AddVariable:
        temp = Left$(temp, Len(temp) - 2)
        temp = Left$(temp, LOKEY + KEYLEN) & PutVariable & "=" & PutValue & vbCrLf & Mid$(temp, LOKEY + KEYLEN + 1)
        GoTo TrimFinalString:
       
RenewVariable:
        temp = Left$(temp, Len(temp) - 2)
        VARENDOFLINE = InStr(VAR, temp, Chr$(13))
        temp = Left$(temp, VAR) & PutVariable & "=" & PutValue & Mid$(temp, VARENDOFLINE)
        GoTo TrimFinalString:

TrimFinalString:
        temp = Mid$(temp, 2)
        Do Until InStr(temp, vbCrLf & vbCrLf & vbCrLf) = 0
        temp = Replace(temp, vbCrLf & vbCrLf & vbCrLf, vbCrLf & vbCrLf)
        Loop
   
        Do Until Right$(temp, 1) > Chr$(13)
        temp = Left$(temp, Len(temp) - 1)
        Loop
   
        Do Until Left$(temp, 1) > Chr$(13)
        temp = Mid$(temp, 2)
        Loop
   
OutputAmendedINIFile:
        Open INIpath For Output As NF
        Print #NF, temp
        Close NF
   
End Function


Enjoy the code!

gravatar

How to Read .INI Files in Visual Basic 6

Option Explicit

Public Function ReadIniValue(INIpath As String, KEY As String, Variable As String) As String
Dim NF As Integer
Dim temp As String
Dim LcaseTemp As String
Dim ReadyToRead As Boolean
   
AssignVariables:
        NF = FreeFile
        ReadIniValue = ""
        KEY = "[" & LCase$(KEY) & "]"
        Variable = LCase$(Variable)
   
EnsureFileExists:
    Open INIpath For Binary As NF
    Close NF
    'SetAttr INIpath, vbArchive
   
LoadFile:
    Open INIpath For Input As NF
    While Not EOF(NF)
    Line Input #NF, temp
    LcaseTemp = LCase$(temp)
    If InStr(LcaseTemp, "[") <> 0 Then ReadyToRead = False
    If LcaseTemp = KEY Then ReadyToRead = True
    If InStr(LcaseTemp, "[") = 0 And ReadyToRead = True Then
        If InStr(LcaseTemp, Variable & "=") = 1 Then
            ReadIniValue = Mid$(temp, 1 + Len(Variable & "="))
            Close NF: Exit Function
            End If
        End If
    Wend
    Close NF
End Function

gravatar

Kevern Solutions: Reporting with Crystal Reports in vb6

Kevern Solutions: Reporting with Crystal Reports in vb6: "Private Sub cmdPrint_Click() Dim rsAccess_level As New ADODB.Recordset Dim rptApps As New CRAXDRT.Appl..."

gravatar

Reporting with Crystal Reports in vb6

Private Sub cmdPrint_Click()
    Dim rsAccess_level As New ADODB.Recordset
    Dim rptApps As New CRAXDRT.Application
    Dim rptReport As New CRAXDRT.Report
            With rsAccess_level
                If .State = adStateClosed Then
                    '.Open "Select * from Folder_Checklist where AcctName'" & txtCustName & "'", ConnModule.conn, adOpenDynamic, adLockOptimistic
                    .Open "Select * from Access_level", ConnModule.conn, adOpenDynamic, adLockOptimistic
                    On Error GoTo errHandler:
                End If
                        'Screen.MousePointer = vbHourglass
                        Set rptApps = CreateObject("CrystalRunTime.Application")
                        Set rptReport = rptApps.OpenReport(App.path & "\reports\Access_level_Rep.rpt")
                        frmReport.CRViewer91.ReportSource = rptReport
                             rptReport.Database.SetDataSource rsAccess_level
                             rptReport.PaperSize = crPaper10x14
                        On Err GoTo errHandler:
                        frmReport.CRViewer91.ViewReport
                        frmReport.CRViewer91.Refresh
                        frmReport.CRViewer91.Zoom 90
                        Screen.MousePointer = vbDefault
                        On Error GoTo errHandler:
            End With
            Exit Sub
errHandler:
        MsgBox Err.Description, vbCritical, "Access Level: Print Error"
End Sub

gravatar

How to trim textboxes in VB6?

 As part of the data validation, trimming of text space with in a textbox is very important.

Here is the Code:

If Trim(txtAccCode.Text) = "" Then
        MsgBox "Account Code is Required!", vbCritical, "MCRP - Access Level: Save Error"
        txtAccCode.SetFocus
        txtAccCode.BackColor = vbYellow
        Exit Sub
    End If

gravatar

How to search data in Visual Basic 6?

Adding a search button on your system is such a good idea, It depends on you what is "Searchable"  on your system, it can be: Customer Code/Item Code/Last Names/ etc.... Here in this method I used Customer No. as searchable string.

The Code:
Private Sub cmdsearchnow_Click()
Dim CN As ADODB.Connection
Dim rs As ADODB.Recordset
Dim Y As Integer
On Error Resume Next
OpenDataFiles CN, rs, "YOURDATABASE.MDB", "SELECT * FROM CUSSTOMERS ORDER BY LASTNAME"

If Not rs.BOF And rs.EOF Then
  rs.MoveFirst
End If
c = 0
Do While Not rs.EOF
 If rs!CustomerNo= txtSearchCustomer.Text Then
 

  With rs
    txtpassbookno.Text = !passbookno
'Place all rs here to appear on textbox after search.
        c = 1
     End With
 End If
    If c = 1 Then
          End If
rs.MoveNext
Loop
    If c = 0 Then 'if no match to the access database (return false)
       MsgBox "Sorry Record not found..."
       Exit Sub
    End If
' Call cleared 'this is optional, you can create on later.
End Sub

gravatar

How to populate combo box in Visual Basic 6?

Here in this source code sample we will discuss how to capture data from you Database Table and displays those data in a combo box.


In this method you can prevent data to be hard coded into your system, we will just have a lookup and displays those lookups in the combo box.

The Code:
First copy this code into your Modules

Option Explicit
    Dim conn As ADODB.connection
    Dim rs As ADODB.Recordset
-------------------------------------------------
' pupulate element
' @author: Ken
' @date: checkDate 07/28/2009
Public Sub init()
    Set conn = New ADODB.connection
    Set rs = New ADODB.Recordset
        conn.connectionString = connectionString.connectionString
            With conn
                On Error GoTo errHandler
                .Open
            End With
        Exit Sub
errHandler:
    MsgBox Err.Description, vbCritical + vbOKOnly, " Admin: Populate Element Module - Init"
End Sub

Public Sub populateCombo(KeyToCollect As String, dboQuery As String, combo As ComboBox)
    Call init
    combo.Clear
            With rs
                'On Error GoTo errHandler
                On Error Resume Next
                If .State = adStateClosed Then
                    .Open dboQuery, conn, adOpenKeyset, adLockOptimistic
                End If
                    Do While Not .EOF
                        combo.AddItem .Fields(KeyToCollect)
                        .MoveNext
                    Loop
                .Close
            End With
        conn.Close
    Exit Sub
errHandler:
    MsgBox Err.Description, vbCritical + vbOKOnly, "Admin: Populate Element MOdule - Populate Combo: Error"
End Sub

'Next is calling the module:
Call PopulateElement.populateCombo("Your Query Here")

Just Experiment on the code and you'll see the best of it.
Good Luck!!!!

gravatar

How to Validate textbox with Javascript?

This script checks if the text box has value or none. The text box that you are going to validate must be inside the form.

<script language="javascript" type="text/javascript">
<!-- hide script from older browsers
function validateForm(MyForm){

    if ("Username"==document.forms.MyForm.UserName.value){
    alert("Username is Required!");
    document.getElementById('UserName').style.color = '#FF0000';
    document.getElementById('UserName').focus();
    return false;
    }
}
</script>

gravatar

How to Connect Visual Basic 6 to MSAccess?

 I have created two types of connections string, first is the database file is targeted via patch provided.

Sub OpenDataFiles(ByRef adConnData As ADODB.Connection, ByRef adrsdata As ADODB.Recordset, ByVal adfile As String, ByVal squery As String)
Dim connstring As String
Set adConnData = New ADODB.Connection
If adfile = "" Then adfile = "c:\mydatabase\data.mdb"
connstring = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\" & adfile
adConnData.ConnectionString = connstring
adConnData.Open
adConnData.CursorLocation = adUseClient
Set adrsdata = New ADODB.Recordset
adrsdata.Open squery, adConnData, adOpenKeyset, adLockOptimistic
End Sub

Two, the Access database file is placed along the program folder.

Sub OpenDataFiles(ByRef adConnData As ADODB.Connection, ByRef adrsdata As ADODB.Recordset, ByVal adfile As String, ByVal squery As String)
Dim connstring As String
Set adConnData = New ADODB.Connection
connstring = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "database.mdb" adConnData.ConnectionString = connstring
adConnData.Open
adConnData.CursorLocation = adUseClient
Set adrsdata = New ADODB.Recordset
adrsdata.Open squery, adConnData, adOpenKeyset, adLockOptimistic
End Sub

Regardless of the path, you can specify it on the Visual Basic 6.0 Data Environment.

gravatar

How to configure the Apache Conf File?

Right after the installation it is now time to configure the conf file in order for the apache function with your php file. Please be reminded that here in this tutorial I used Apache 2.0.63 for 32bit. The httpd is located at this path, <C:\Program Files\Apache Group\Apache2\conf> or depends on you installation path upon installation.

Configuring the ServerRoot:
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "C:/Program Files/Apache Group/Apache2"

Configuring you ports:
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 11.34.11.12:80
Listen 80

Configuring Server Admin and Server Name:
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin admin@yournetwork.com.ph

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName Your Machine Name.YourNetwork.com.ph:80

Configuring the document root:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"

# If you prefer a single logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog logs/access.log combined

This is for your virtual host but this is optional.
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

This is for the php5 Configurations:
# For PHP 5
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

Testing your Apache HTTP Server:
Type: localhost to your browser's Address Bar.


If you see this in your browser. This means the apache service is running well and ready.


Good Luck and Have fun with Apache + php

gravatar

How to Populate MshFlexgrid in vb6

Create a module on your vb6 project and name that module PopulateGridModule. Then paste this code. Be sure that you have already established a database connection on you MySql or Access database. or else this method will not run.

Here is my connection type: Check it out for your reference.

Public Function connectionString()
    connectionString = "DRIVER={" & ReadIniValue(App.Path & "\conme.ini", "DEFAULT", "DRIVER") & "};" _
                      & "SERVER=" & ReadIniValue(App.Path & "\conme.ini", "DEFAULT", "HOST") & ";" _
                      & "DATABASE=" & ReadIniValue(App.Path & "\conme.ini", "DEFAULT", "DBNAME") & ";" _
                      & "UID=" & ReadIniValue(App.Path & "\conme.ini", "DEFAULT", "UID") & ";" _
                      & "PWD=" & ReadIniValue(App.Path & "\conme.ini", "DEFAULT", "PWD") & ";" _
                      & "OPTION=3"
End Function

A Simple reminder!, here in this connection string I used the conme.ini method.

Now this code will populate the MSHFlexGrid on your project.
Public Sub populateFlexGrids(dboQuery As String, grid As MSHFlexGrid)
    Call init
    grid.Clear
        With rs
            On Error GoTo errHandler
            .Open dboQuery, conn, adOpenKeyset, adLockOptimistic
            If rs.RecordCount = 0 Then
                MsgBox "No Data Found!", vbCritical, "POS Message:"
                Set grid.DataSource = rs
            Else
                Set grid.DataSource = rs
            End If
            .Close
        End With
        conn.Close
    Dim columnWidth As Double
    Dim counter As Integer
            columnWidth = (grid.Width / grid.Cols)
            If columnWidth <= 2000 Then
                columnWidth = 2000
            End If
            For counter = 0 To grid.Cols
                grid.ColWidth(counter) = columnWidth
            Next counter
        grid.Refresh
    Exit Sub
errHandler:
    MsgBox Err.Description, vbCritical + vbOKOnly, "Admin: Populate Element Module - Populate Flexgrid: Error"
End Sub

Then call this function:
Call PopulateGridModule.populateFlexgrids("Select * from YOUTABLE", MSHFlexgrid1)
Now you can put this code OnLoad or OnClick.

Good Luck!

gravatar

How to hardcode User Name and Password in vb6?

Hard coding user name and password in a system is not a good idea, the reason is, how about if you add new user's and end user's in the system???? , of course you have to re compile your codes, which is not a good idea, Anyway here are some samples of my hard coded user name and password. I only used this codes when I started vb6 programming in college.



The Codes

Option Explicit
Public COUNT1 As Integer
Public LoginSucceeded As Boolean

Private Sub cmdCancel_Click()
    'set the global var to false
    'to denote a failed login
    LoginSucceeded = False
    Me.Hide
End Sub

Private Sub cmdOK_Click()
On Error Resume Next
    'check for correct password
    If UCase(txtusername.Text) = "ADMINISTRATOR" And UCase(txtpassword) = "ADMIN" _
       Or UCase(txtusername.Text) = "ADMIN" And UCase(txtpassword) = "ADMIN123" _
       Or UCase(txtusername.Text) = "USER1" And UCase(txtpassword) = "USER1" _
       Or UCase(txtusername.Text) = "USER2" And UCase(txtpassword) = "USER2" _
       Or UCase(txtusername.Text) = "USER3" And UCase(txtpassword) = "USER3" _
       Or UCase(txtusername.Text) = "USER4" And UCase(txtpassword) = "USER4" Then
        'place code to here to pass the
        'success to the calling sub
        'setting a global var is the easiest
        LoginSucceeded = True
        Me.Hide
        'Form4.Show
        MainSplash.Show
        GoTo JUMP
    Else
        MsgBox "Invalid Password, try again!", , "Login"
        txtpassword.SetFocus
        SendKeys "{Home}+{End}"
    End If
       COUNT1 = COUNT1 + 1
         If COUNT1 = 3 Then
            MsgBox "Access in not Allowed!"
            End
         End If
JUMP:
     Exit Sub
End Sub

-In this method the user is given 3 attempts to login if the user fails to enter the correct username and password, the system automatically exit. Here in this method you can add your own, maybe you can add after 3 attempts the pc will automatically shutdown... it's up to you, base on your system security reasoning...

Good Luck!

gravatar

How to delete data from Access Database in Visual Basic 6

Private Sub cmddelete_Click()
Dim CN As ADODB.Connection
Dim rs As ADODB.Recordset
Dim Y As Integer
On Error Resume Next
OpenDataFiles CN, rs, "YOURDATA.MDB", "SELECT * FROM MEMBER"


cmdsave.Enabled = True
If Not rs.BOF And rs.EOF Then
  rs.MoveFirst
End If

Do While Not rs.EOF
 If rs!customerno= txtcustomerno.Text Then
   ans = MsgBox("Delete this Record?", vbYesNo, "Deletion Verification")
     If ans = vbYes Then
        rs.Delete
     End If
 End If
 rs.MoveNext
 Loop
     'Call cleared 'this is optional based on your own code
 
 CN.close
 rs.close
 OpenDataFiles CN, rs, "YOURDATA.MDB", "SELECT * FROM MEMBER order by LNAME"
   
If Not rs.BOF And rs.EOF Then
   rs.MoveFirst
End If

Grid1.Refresh
Grid1.Rows = 1

Do While Not rs.EOF
'  If rs!passbookno = txtpassbookno.Text Then
     Grid1.AddItem rs!customerno 'you can specify you recordset here, if you want to update some of your Grids if you have one.
  End If
rs.MoveNext
Loop

Call cleared 'this is optional based on your own code.
End Sub

gravatar

Using Crystal Report 9 in Visual Basic Reports

Author: Kevern V.
BuildDate: 02/03/2009
Version: v1.1.0

'Code to Command Button
Private Sub cmdPrint_Click()
    Dim rsCollection As New ADODB.Recordset
    Dim rptApps As New CRAXDRT.Application
    Dim rptReport As New CRAXDRT.Report
            With rsCollection
                If .State = adStateClosed Then
                       .Open "Select * from YourTables", ConnModule.conn, adOpenDynamic, adLockOptimistic
                    On Error GoTo errHandler:
                End If
                        Screen.MousePointer = vbHourglass
                        Set rptApps = CreateObject("CrystalRunTime.Application")
                        Set rptReport = rptApps.OpenReport(App.path & "\reports\Collection_Rep.rpt") 'Your Report Folder
                        frmReport.CRViewer91.ReportSource = rptReport
                             rptReport.Database.SetDataSource rsCollection
                             rptReport.PaperSize = crPaper10x14
                                On Err GoTo errHandler:
                        frmReport.CRViewer91.ViewReport
                        frmReport.CRViewer91.Refresh
                        frmReport.CRViewer91.Zoom 90
                        Screen.MousePointer = vbDefault
                        On Error GoTo errHandler:
            End With
            Exit Sub
errHandler:
        MsgBox Err.Description, vbCritical, "Admin- System Error: Reports"
End Sub