Dim tables() as String
Dim tablename as String
Dim msg as String
msg = IsInArray(tablename, tables())
Public Function IsInArray(FindValue As Variant, arrSearch As Variant) As Boolean
On Error GoTo LocalError
If Not IsArray(arrSearch) Then Exit Function
If Not IsNumeric(FindValue) Then FindValue = LCase(FindValue)
IsInArray = InStr(1, vbNullChar & Join(arrSearch, vbNullChar) & vbNullChar, _
vbNullChar & FindValue & vbNullChar) > 0
Exit Function
LocalError:
'Justin (just in case)
End Function
ASP.NET is a development framework for building web pages and web sites with HTML, CSS, JavaScript and server scripting. ASP.NET supports three different development models: Web Pages, MVC (Model View Controller), and Web Forms.
Friday, July 17, 2009
Minimize VB 6.0 Application to TaskBar and checking if it is already running
Open a new standard project in vb 6.0
Then add a module named modPublic.bas in the project and add the following code in the module which are the public declaration and API call code:
Option Explicit
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As MinimiseIconData) As Boolean
'constants required by Shell_NotifyIcon API call:
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Then add other module named modType for the public type declaration for the project. Add the following code in this module:
Public Type MinimiseIconData
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Then on the Form1 properties select the icon which you want to display when your application is minimised to the task bar.
Note: icon has the extention .ico
Add one command button on the form
Then in the Form1 code page add the following code:
Option Explicit
Private minIco As MinimiseIconData
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
If App.PrevInstance Then
End
End If
With minIco
.cbSize = Len(minIco)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon ' <== You can change this to another icon
.szTip = "Double-click this icon to make the application visible" & vbNullChar ' <== You can change this also.
End With
Shell_NotifyIcon NIM_ADD, minIco
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngButtonAction As Long
lngButtonAction = X / Screen.TwipsPerPixelX
Select Case lngButtonAction
Case WM_LBUTTONDBLCLK
' Left mouse button has been double clicked
' If app is currently minimized ….
Me.WindowState = vbNormal
Me.Show
'If Me.WindowState = vbMinimized Then ' … then restore it to normal size
' Me.WindowState = vbNormal
' Shell_NotifyIcon NIM_DELETE, nid ' and remove the icon
'ElseIf Not Me.Visible Then ' Else, if the app is hidden …
' Me.Show ' then show the form again
' Me.WindowState = vbNormal
' Shell_NotifyIcon NIM_DELETE, nid ' and remove the icon
'End If
Case WM_LBUTTONDOWN
' You could put code in here to make something happen when
' left mouse button is single clicked on the icon
Case WM_RBUTTONDOWN
' You could put code in here to make something happen when
' right mouse button is single clicked on the icon
End Select
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.WindowState = vbMinimized Then
Me.Hide
Shell_NotifyIcon NIM_ADD, minIco
Else ' otherwise don't show it
Me.Show
Shell_NotifyIcon NIM_DELETE, minIco ' รง This removes the icon
End If
End Sub
Private Sub Form_Terminate()
Shell_NotifyIcon NIM_DELETE, minIco
End Sub
Then add a module named modPublic.bas in the project and add the following code in the module which are the public declaration and API call code:
Option Explicit
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As MinimiseIconData) As Boolean
'constants required by Shell_NotifyIcon API call:
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Then add other module named modType for the public type declaration for the project. Add the following code in this module:
Public Type MinimiseIconData
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Then on the Form1 properties select the icon which you want to display when your application is minimised to the task bar.
Note: icon has the extention .ico
Add one command button on the form
Then in the Form1 code page add the following code:
Option Explicit
Private minIco As MinimiseIconData
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
If App.PrevInstance Then
End
End If
With minIco
.cbSize = Len(minIco)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon ' <== You can change this to another icon
.szTip = "Double-click this icon to make the application visible" & vbNullChar ' <== You can change this also.
End With
Shell_NotifyIcon NIM_ADD, minIco
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngButtonAction As Long
lngButtonAction = X / Screen.TwipsPerPixelX
Select Case lngButtonAction
Case WM_LBUTTONDBLCLK
' Left mouse button has been double clicked
' If app is currently minimized ….
Me.WindowState = vbNormal
Me.Show
'If Me.WindowState = vbMinimized Then ' … then restore it to normal size
' Me.WindowState = vbNormal
' Shell_NotifyIcon NIM_DELETE, nid ' and remove the icon
'ElseIf Not Me.Visible Then ' Else, if the app is hidden …
' Me.Show ' then show the form again
' Me.WindowState = vbNormal
' Shell_NotifyIcon NIM_DELETE, nid ' and remove the icon
'End If
Case WM_LBUTTONDOWN
' You could put code in here to make something happen when
' left mouse button is single clicked on the icon
Case WM_RBUTTONDOWN
' You could put code in here to make something happen when
' right mouse button is single clicked on the icon
End Select
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.WindowState = vbMinimized Then
Me.Hide
Shell_NotifyIcon NIM_ADD, minIco
Else ' otherwise don't show it
Me.Show
Shell_NotifyIcon NIM_DELETE, minIco ' รง This removes the icon
End If
End Sub
Private Sub Form_Terminate()
Shell_NotifyIcon NIM_DELETE, minIco
End Sub
Tuesday, April 28, 2009
DateTime Convertion in 24 Hour Format
private string dateConvert(string datDate){
System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB");
System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US");
DateTime dtGb = Convert.ToDateTime(datDate, cultEnGb.DateTimeFormat); datDate = dtGb.ToString(cultEnUs.DateTimeFormat.ShortDatePattern);
return datDate;}
System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB");
System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US");
DateTime dtGb = Convert.ToDateTime(datDate, cultEnGb.DateTimeFormat); datDate = dtGb.ToString(cultEnUs.DateTimeFormat.ShortDatePattern);
return datDate;}
Monday, April 27, 2009
ASP.Net 2.0 C# DateTime IFormatProvider Using ParseExact
In the previous article C# Convert String to DateTime you learnt the use of Convert.ToDateTime function in C# ASP.Net 2.0. Following are 2 other methods to convert the DateTime format using IFormatProvider:
DateTime .ParseExact
DateTime.Parse
To use IFormatProvider you have to pass the culture info for DateTime format coz in different cultures DateTime format of displaying the sequence of month and date varies.
E.g.:
For French Culture use the following:
IFormatProvider culture = new CultureInfo("fr-Fr", true);
For US English use the following:
IFormatProvider culture = new CultureInfo("fr-Fr", true);
Both cultures mentioned above accept the different DateTime Formats.
If you are using
DateTime.Parse
then you have to pass the MM/dd/yyyy hh:mm:ss
Format of DateTime for French culture and dd/MM/yyyy hh:mm:ss for US English culture. You have to check the format for different cultures by changing the position of month and day.
Using DateTime Parse:
dt = DateTime.Parse(myDateTimeString, culture,DateTimeStyles.NoCurrentDateDefault);
Using DateTime ParseExact:
dt = DateTime.ParseExact(myDateTimeString,"MM/dd/yyyy hh:mm:ss", culture, DateTimeStyles.NoCurrentDateDefault);
C# Code to ParseExact the DateTime String:
string myDateTimeString;
myDateTimeString = "19/02/2008 05:44:00";
IFormatProvider culture = new CultureInfo("fr-Fr", true);
dt = DateTime.ParseExact(myDateTimeString,"dd/MM/yyyy hh:mm:ss", culture, DateTimeStyles.NoCurrentDateDefault);
Response.Write(dt.Day + "/" + dt.Month + "/" + dt.Year);
DateTime .ParseExact
DateTime.Parse
To use IFormatProvider you have to pass the culture info for DateTime format coz in different cultures DateTime format of displaying the sequence of month and date varies.
E.g.:
For French Culture use the following:
IFormatProvider culture = new CultureInfo("fr-Fr", true);
For US English use the following:
IFormatProvider culture = new CultureInfo("fr-Fr", true);
Both cultures mentioned above accept the different DateTime Formats.
If you are using
DateTime.Parse
then you have to pass the MM/dd/yyyy hh:mm:ss
Format of DateTime for French culture and dd/MM/yyyy hh:mm:ss for US English culture. You have to check the format for different cultures by changing the position of month and day.
Using DateTime Parse:
dt = DateTime.Parse(myDateTimeString, culture,DateTimeStyles.NoCurrentDateDefault);
Using DateTime ParseExact:
dt = DateTime.ParseExact(myDateTimeString,"MM/dd/yyyy hh:mm:ss", culture, DateTimeStyles.NoCurrentDateDefault);
C# Code to ParseExact the DateTime String:
string myDateTimeString;
myDateTimeString = "19/02/2008 05:44:00";
IFormatProvider culture = new CultureInfo("fr-Fr", true);
dt = DateTime.ParseExact(myDateTimeString,"dd/MM/yyyy hh:mm:ss", culture, DateTimeStyles.NoCurrentDateDefault);
Response.Write(dt.Day + "/" + dt.Month + "/" + dt.Year);
Saturday, March 21, 2009
Windows form close and open next form in Windows Application in C#.NET
Form2 Form2 = new Form2();
Form2.StartPosition = FormStartPosition.CenterParent;
this.Hide();
Form2.ShowDialog();
this.Close();
Form2.StartPosition = FormStartPosition.CenterParent;
this.Hide();
Form2.ShowDialog();
this.Close();
Wednesday, March 4, 2009
Find if a value exists in an Array in VB6.0
Module:
Option Explicit
Public Function IsInArray(FindValue As Variant, arrSearch As Variant) As Boolean
On Error GoTo LocalError
If Not IsArray(arrSearch) Then Exit Function
If Not IsNumeric(FindValue) Then FindValue = UCase(FindValue)
IsInArray = InStr(1, vbNullChar & Join(arrSearch, vbNullChar) & vbNullChar, _
vbNullChar & FindValue & vbNullChar) > 0
Exit Function
LocalError:
'Justin (just in case)
End Function
Usage:
Private Sub Command1_Click()
Dim x(5) As String
x(0) = 5
x(1) = 100
x(2) = 2000
x(3) = 11
x(4) = 7
x(5) = 1010
MsgBox IsInArray(10, x)
End Sub
Option Explicit
Public Function IsInArray(FindValue As Variant, arrSearch As Variant) As Boolean
On Error GoTo LocalError
If Not IsArray(arrSearch) Then Exit Function
If Not IsNumeric(FindValue) Then FindValue = UCase(FindValue)
IsInArray = InStr(1, vbNullChar & Join(arrSearch, vbNullChar) & vbNullChar, _
vbNullChar & FindValue & vbNullChar) > 0
Exit Function
LocalError:
'Justin (just in case)
End Function
Usage:
Private Sub Command1_Click()
Dim x(5) As String
x(0) = 5
x(1) = 100
x(2) = 2000
x(3) = 11
x(4) = 7
x(5) = 1010
MsgBox IsInArray(10, x)
End Sub
Tuesday, March 3, 2009
VB code to show all table names of a databse
Dim rs As ADODB.Recordset
Dim con As New ADODB.Connection
Dim tables() As String
Dim table1, tablename As String
Dim i As Integer
Private Sub Command1_Click()
If con.State = adStateOpen Then
con.Close
End If
con.Open "Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=GMS;Integrated Security=SSPI"
Set rs = New ADODB.Recordset
Set rs = con.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
Do Until rs.EOF
'MsgBox rs!table_name
'Combo1.AddItem (rs!table_name)
If table1 = "" Then
table1 = rs!table_name
Else
table1 = table1 & "," & rs!table_name
End If
rs.MoveNext
Loop
rs.Close
tablename = "adcdata"
Set rs = Nothing
tables() = Split(table1, ",")
For i = 0 To UBound(tables()) - 1
If tablename = tables(i) Then
MsgBox "yes"
Else
End If
Next i
MsgBox table1
End Sub
Private Sub Form_Load()
'con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & " data source=" & App.Path & "\rubberpark.mdb"
End Sub
Dim con As New ADODB.Connection
Dim tables() As String
Dim table1, tablename As String
Dim i As Integer
Private Sub Command1_Click()
If con.State = adStateOpen Then
con.Close
End If
con.Open "Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=GMS;Integrated Security=SSPI"
Set rs = New ADODB.Recordset
Set rs = con.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
Do Until rs.EOF
'MsgBox rs!table_name
'Combo1.AddItem (rs!table_name)
If table1 = "" Then
table1 = rs!table_name
Else
table1 = table1 & "," & rs!table_name
End If
rs.MoveNext
Loop
rs.Close
tablename = "adcdata"
Set rs = Nothing
tables() = Split(table1, ",")
For i = 0 To UBound(tables()) - 1
If tablename = tables(i) Then
MsgBox "yes"
Else
End If
Next i
MsgBox table1
End Sub
Private Sub Form_Load()
'con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & " data source=" & App.Path & "\rubberpark.mdb"
End Sub
Subscribe to:
Posts (Atom)
Using Authorization with Swagger in ASP.NET Core
Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models { ...
-
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.D...
-
string[] Files; var root = Application.ExecutablePath; ...
-
Inbox.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/Marketing/admin.master" EnableEventValid...