Luc001 77 Posting Whiz

Hi,

You can try this:

Label1.Text = ListView1.Items.Count()Label1.Text = ListView1.Items.Count()
Luc001 77 Posting Whiz

Hi,

You need to add those images into the resources files like this:

PictureBox1.Image = My.Resources.imagename

You can find the whole explanation, here.

Luc001 77 Posting Whiz

Hi,

You can work around and use enabled and set backcolor to white.
Here's an example:

For Each ctrl As Control In Me.Controls
            If TypeOf ctrl Is TextBox Then
                ctrl.Enabled = False
                ctrl.BackColor = Color.White
            End If
        Next
Luc001 77 Posting Whiz

Hi,

I think you can find some information, here.

Luc001 77 Posting Whiz

Hi,

Here's an example how to create a Login form with a database:

Imports System.Data.OleDb   
  
Public Class LoginForm1   
  
    ' OK button   
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click   
        Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=E:\VBproject\myDB.mdb")   
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Users WHERE userid = '" & usernametextbox.Text & "' AND password = '" & passwordtextbox.Text & "' ", con)   
        con.Open()   
        Dim sdr As OleDbDataReader = cmd.ExecuteReader()   
        ' If the record can be queried, Pass verification and open another form.   
        If (sdr.Read() = True) Then  
            MessageBox.Show("The user is valid!")   
            Dim mainForm As New MainForm   
            mainForm.Show()   
            Me.Hide()   
        Else  
            MessageBox.Show("Invalid username or password!")   
        End If  
    End Sub  
  
    ' Cancel button   
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click   
        Me.Close()   
   End Sub  
  
End Class
Luc001 77 Posting Whiz

Hi,

After looking up the error found that you've got a Virus on your computor that could be the WORM_KLEZ.E .

You can try to do a Total scan with your Antivirus or do a Registry Clean.

You can find some information about the virus and a solution, here.

Luc001 77 Posting Whiz

Hi,

Here's how I did it to draw a circle with a timer.

Public Class Form1
    Dim count As Integer = 0 ' start count of counter

    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub TestButton_Click(ByVal sender As System.Object, _
                                 ByVal e As System.EventArgs) Handles Testbutton.Click
        Timer1.Enabled = True
    End Sub
    Private Sub Timer1_Tick(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Timer1.Tick
        count += 1
        Dim x As Integer
        x = -90 + count
        Dim mypen As New Pen(Color.Black, 3)
        picOut.CreateGraphics.DrawArc(mypen, 50, 50, 125, 125, x, CInt(count))
        picOut.CreateGraphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        If count = 180 Then
            count = 0  ' to reset the counter
            picOut.Refresh() ' to reset the picturebox
        End If
    End Sub

' In the paint event of the picturebox piant an Ellipse with a Red color.
        Private Sub picOut_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picOut.Paint
        Dim mypen As New Pen(Color.Red, 3)
        e.Graphics.DrawEllipse(mypen, 50, 50, 125, 125)
        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
    End Sub
End Class
Luc001 77 Posting Whiz

Hi,

You can try this:

Private Function AlphabeticSort(ByVal dtTable As DataTable, ByVal sortOrder As Integer) As DataTable   
        Dim dsSorted As New DataSet
        Dim columnKey As String = "TabName"
        Dim sortDirection As String = ""
        Dim sortFormat As String = "{0} {1}"
        Select Case sortOrder
            Case 0
                sortDirection = "ASC"
            Case 1
                sortDirection = "DESC"
            Case Else
                sortDirection = "ASC"
        End Select
        dtTable.DefaultView.Sort = String.Format(sortFormat, columnKey, sortDirection)
        Return dtTable.DefaultView.Table
    End Function
Luc001 77 Posting Whiz

Hi,

What you can try is to enable the add rows button until the row is added.

This is just a suggestion, bacause without code is it very difficult to answer.

Luc001 77 Posting Whiz

Hi,

You should read this thread.

Luc001 77 Posting Whiz

Hi,

I think you can find some information, here.

Luc001 77 Posting Whiz

Hi,

You can find some information about how to create a Phonebook with VB.Net, here.

Luc001 77 Posting Whiz

Hi,

I don't know of an easy way to do it using a ListBox control.
I would use a ListView control instead. This typically gives
you more features anyway, not to mention. From what I have discovered using the ListBox control, you can only set the ForeColor for the entire control, not the individual items within the control.
If you would like to use the ListView control instead, here some sample code to do what you wanted to do.

Just drag a ListView control onto your form, or build it dynamically,
whichever you prefer, and then add the following code:

Private Sub BuildListView
Dim i As Integer
ListView1.View = View.Details
ListView1.Columns.Add("Column1", 200, HorizontalAlignment.Left)
For i = 0 To 3
Dim x As New ListViewItem
Select Case i
Case 0
x.Text = "Red text goes here..."
x.ForeColor = System.Drawing.Color.Red
Case 1
x.Text = "Blue text goes here..."
x.ForeColor = System.Drawing.Color.Blue
Case 2
x.Text = "Green text goes here..."
x.ForeColor = System.Drawing.Color.Green
Case 3
x.Text = "Black text goes here..."
x.ForeColor = System.Drawing.Color.Black
End Select
ListView1.Items.Add(x)
Next i
End Sub

I hope it will help you in right direction.

Luc001 77 Posting Whiz

Hi,

I think this could be useful.

Or this.

Luc001 77 Posting Whiz

Hi,
You mentioned:

the problem is that RGB has three cordinates like RGB(0, 0 , 0), as Point can have only two cordinates poit(x,y) so i have force my self to make it RGB(0,0)... does it effect my code????

Yes, It will affect your code with this error:

Value of type 'Integer' cannot be converted to 'System.Drawing.Color'.

So, That's not an option.

Luc001 77 Posting Whiz

Hi,

No problem glad to help.
Mark it as solved.

Luc001 77 Posting Whiz

Hi,

You could use something like this:

Dim x As Integer
        Dim y As Integer
        Cursor.Position = New Point(x + 2, y) 
       Cursor.Position = New POint(X, Y +2)
Luc001 77 Posting Whiz

Hi,

Here's a way how to detect the color in a shape.
Add a label to show the color.

Public Class Form1
    Public path As New System.Drawing.Drawing2D.GraphicsPath
    Public thecolor As Color = Color.Aqua
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        path.AddEllipse(20, 160, 50, 50)

    End Sub

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        If path.IsVisible(e.X, e.Y) Then
            Label1.BackColor = thecolor
        End If
    End Sub
    
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim brl As SolidBrush
        brl = New SolidBrush(thecolor)
        e.Graphics.FillPath(brl, path)
                
    End Sub
End Class
Luc001 77 Posting Whiz

Hi,

Here's an example how to create an Ellipse and show the same color as the pixel color.

Public Class Form1

    Public MyColor As Color
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
        PictureBox1.Image = My.Resources. your picturename
        Dim TempBitmap As New Bitmap(PictureBox1.Image)
        MyColor = TempBitmap.GetPixel(e.X, e.Y)
        Me.Invalidate()
        End Sub
    
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

        Dim g As Graphics = e.Graphics
        Dim brs As SolidBrush
        brs = New SolidBrush(MyColor)
        g.FillEllipse(brs, 20, 20, 50, 50)
        
    End Sub
End Class
Luc001 77 Posting Whiz

Hi,

You can use an Imagelist to do so, and then show the images into your panel.

You can find some explanation, here.

Luc001 77 Posting Whiz

Hi,

Did you used the installutil in order to install your service, there's no other way to do this if you dont have the .Net Framework runnig on your machine. The alturnatives if you are using normal CMD are :-

1. On VS 2003 : C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe C:\MyService.exe

2 On VS 2005 Express : C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe

Luc001 77 Posting Whiz

Hi,

A Windows Services is a new name for a NT Services you used to develop in previous versions of Visual Studio. This Service writes some text to a text file when stop and start the service.

i can see the service name in the services option in administrative tools

Did you started the service?

Cheque in your temp directory if there is a text file with contents or not.

Otherwise, here's a tutorial how to create a windows service with VB.Net.

Luc001 77 Posting Whiz

Hi,

Here's an example how to do this.

Public Class SplitTest
    Public Shared Sub Main()
        Dim words As String = "This is a list of words, with: a bit of punctuation" + _
                              vbTab + "and a tab character."
        Dim split As String() = words.Split(New [Char]() {" "c, ","c, "."c, ":"c, CChar(vbTab) })

        For Each s As String In  split
            If s.Trim() <> "" Then
                Console.WriteLine(s)
            End If
        Next s
    End Sub 'Main
End Class
Luc001 77 Posting Whiz

Hi,

I think you need to call your your array first and then sorting it.
Try something like this:

Public Class frmBubbleSort
' Declare array with Class (form) scope
Dim players As String() = {"Crawford", "Upton", "Longoria", "Bartlett", "Pena", "Navarro", "Garza", "Shields", "Price", "Neiman"}

Private Sub frmBubbleSort_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Load array into ComboBox
players.Sort(players) ' your arrays name is players then sorting it

cboBubble.MaxDropDownItems = players
cboBubble.DataSource = A

End Sub
Luc001 77 Posting Whiz

Hi,

You can find a complete database with several buttons to navigate into a database. Even with the whole explanation. Look here.

Luc001 77 Posting Whiz

Hi,

You have to change the data (access database) from a byte format into a bitmap format. You can do that with the MemoryStreamClass.

Public Function GetImageFromDB(ByRef imageName As String) As Bitmap 
    Try 
        Dim conn As New OleDb.OleDbConnection 
        Dim cmd As OleDb.OleDbCommand 
        Dim reader As OleDb.OleDbDataReader 
 
        conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\YourDBFile.mdb;" 
        conn.Open() 
 
        cmd = conn.CreateCommand() 
        cmd.CommandText = "SELECT YourColumnName FROM YourTable WHERE ColumnName = '" & imageName & "'" 
        reader = cmd.ExecuteReader 
 
        If reader.Read Then 
            Dim imgByteArray() As Byte 
            Try 
                imgByteArray = CType(reader(0), Byte()) 
                Dim stream As New System.IO.MemoryStream(imgByteArray) 
                Dim bmp As New Bitmap(stream) 
                stream.Close() 
            Catch ex As Exception 
                MessageBox.Show(ex.Message) 
                Return Nothing                     
            End Try 
        End If 
 
        reader.Close() 
        conn.Close() 
 
        cmd.Dispose() 
        conn.Dispose() 
         
        Return bmp             
    Catch ex As Exception 
        MessageBox.Show(ex.Message) 
        Return Nothing             
    End Try 
End Function

Then you need to do something like this:

PictureBox1.Image = GetImageFromDB(TextBox1.Text)
Luc001 77 Posting Whiz

Hi,

You can find an example how to do it, here.

Netcode commented: the link is a bad one -1
Luc001 77 Posting Whiz

Hi,

I think you can some good information about, how to use Crystal Reports with VB.Net, here.

Luc001 77 Posting Whiz

Hi,

You can use a low- level keyboard hook.

Private Declare Function SetWindowsHookEx _
 Lib "user32" Alias "SetWindowsHookExA" ( _
 ByVal idHook As Long, _
 ByVal lpfn As Long, _
 ByVal hmod As Long, _
 ByVal dwThreadId As Long) As Long
  
Private Declare Function CallNextHookEx Lib "user32" ( _
 ByVal hHook As Long, _
 ByVal nCode As Long, _
 ByVal wParam As Long, _
 ByVal lParam As Long) As Long

Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
 ByVal hHook As Long) As Long

Private Declare Sub CopyMemory _
 Lib "kernel32" Alias "RtlMoveMemory" ( _
 pDest As Any, _
 pSource As Any, _
 ByVal cb As Long)

Private Type KBDLLHOOKSTRUCT
    vkCode As Long
    scanCode As Long
    flags As Long
    time As Long
    dwExtraInfo As Long
End Type

Private Const HC_ACTION = 0&
Private Const WH_KEYBOARD_LL = 13&
Private Const VK_LWIN = &H5B&
Private Const VK_RWIN = &H5C&

Private hKeyb As Long

Private Function KeybCallback(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Static udtHook As KBDLLHOOKSTRUCT
    
    If (Code = HC_ACTION) Then
        'Copy the keyboard data out of the lParam (which is a pointer)
        Call CopyMemory(udtHook, ByVal lParam, Len(udtHook))
        Select Case udtHook.vkCode
            Case VK_LWIN, VK_RWIN
                KeybCallback = 1
                Exit Function
        End Select
    End If
    KeybCallback = CallNextHookEx(hKeyb, Code, wParam, lParam)
End Function

Public Sub HookKeyboard()
    UnhookKeyboard
    hKeyb = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeybCallback, App.hInstance, 0&)
End Sub

Public Sub UnhookKeyboard()
    If hKeyb <> 0 Then
        Call UnhookWindowsHookEx(hKeyb)
        hKeyb = 0
    End If
End Sub
Luc001 77 Posting Whiz

Hi,

Show us your codes and we could help you more.

Luc001 77 Posting Whiz

Hi All....
I need to detect when no moving of cursor or keyboard then my form will automatic closing...how to do that..tq

Hi,

You need a timer event to detect when a form is idle for a certain time, then close the form automaticly after the form is idle in the same timer event.

Luc001 77 Posting Whiz

Hi,

You can find an example here.

Luc001 77 Posting Whiz

Hi,

You can find an example here.

Luc001 77 Posting Whiz

Hi,

What is the code to write in txtCaps text box event which can change the whole text entered in as capital letters? Thanks.

Hi,

You need the CharacterCasing property to do so.
Here's an example:

TextBox1.CharacterCasing = CharacterCasing.Upper
Luc001 77 Posting Whiz

Hi,

After some testing found a way to show only one Form.
That means that like in your example you have a Form2.
Now try this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.MdiParent = Me
        Form2.Show()
        Form2.Focus() ' you need to focus it, if it's behind another Form
    End Sub

You'll see that the Form2 will be shown only ones.

Luc001 77 Posting Whiz

Hi,

In addition Adatapost has written:

You need to create a parentform, to do so you can use Form1 and rename it parentform.vb. Then you need to set the property IsMDIContainer = true. When you add a new form to your application you'll see that it will create a Form1 again. Then use Adatapost's code.

kvprajapati commented: Helpful! +9
Luc001 77 Posting Whiz

Hi,

Declare your form2 inside the Button event, like this:

Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm2 As New Form2
        frm2.MdiParent = Me
        frm2.Show()
    End Sub
End Class
Luc001 77 Posting Whiz

i have comleted the project i want to make a taskbar in the
MDI Parent. that behaves same like taskbar, whenever a new form is opened there will be a link for the form, and also having RightClick Menu from which i can close maximize and minimize the form............
is any featcher like this is provided by the microsoft ??
if yes then how to add that ??
if no then how can we design / make our own ??

Hi,

The toolstrip that you can find in the toolbox may do what you need, you can add buttons and remove them in code, and dock it where you want. You find some explanation, here.

For your second question you need to use a contextmenustrip for that. You find some explanation, here.

Luc001 77 Posting Whiz

Hi,

You can sort your datagrid in decending or ascending order.
You can find an example, here.

Luc001 77 Posting Whiz

Hi,

Here's just an example to show you how you can change the datestring.

Dim current As Date = Date.Now
        TextBox1.Text = current
        TextBox2.Text = current.ToShortDateString
Luc001 77 Posting Whiz

I want to create a program that will close itself when the user was idle(not touching/moving the mouse and keyboard) for about 5 minutes...but I have a problem in how to track a user's idle time so that I could set the closing action. Could anyone give me a simple example?

Hi,

You can find some explanation about detecting the Idle time with Mouse and Keyboard hooks, here.

Luc001 77 Posting Whiz

I am vb.net application developer. I like to intstall vb.net software.

Hi,

You find some explanation here.

Luc001 77 Posting Whiz

Hi,

You can try something like this:

TextBox1.Text = ListView1.SelectedItems(0).ToString
Luc001 77 Posting Whiz

Hi,

The error 0xc000007b is telling you do not have the correct drivers for
your hard drive controller for the installation.
That error could be possible caused by a Virus.

Do a Antivirus scan and see what happens.

Luc001 77 Posting Whiz

Hi,

I'm a little confused about your question, so I think that you want to see the times running.

Here's an example how to do it. All you need is to add a timer.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        TextBox1.Text = Now.ToString("G")
        Label1.Text = Format(Now, "hh:mm:ss tt")

    End Sub
Luc001 77 Posting Whiz

Hi,

Try this:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If (e.KeyChar < Chr(48) Or e.KeyChar > Chr(57)) And e.KeyChar <> Chr(8) Then

e.Handled = True

End If

End Sub

Or this:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
as System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub
Luc001 77 Posting Whiz

Hi,

Also Visual Basic 2008 How to Program by Deitel.

Look here.

Luc001 77 Posting Whiz

Hi,

I think you can find some explanation here.

Luc001 77 Posting Whiz

Hi,

I think you should start a New thread, because a few members will look into a solved thread.

Luc001 77 Posting Whiz

Hi,

I found a way how to hide the Menu.
I did it in VB 2003 and added a MainMenu to it.
Now to hide the mainmenu I've used MainMenu1.Dispose like this.

Private Function GetFormImage() As Bitmap
        ' Get this form's Graphics object.
        Dim me_gr As Graphics = Me.CreateGraphics

        ' Make a Bitmap to hold the image.
        Dim bm As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height, me_gr)
        Dim bm_gr As Graphics = me_gr.FromImage(bm)
        Dim bm_hdc As IntPtr = bm_gr.GetHdc

        ' Get the form's hDC. We must do this after 
        ' creating the new Bitmap, which uses me_gr.
        Dim me_hdc As IntPtr = me_gr.GetHdc

        ' BitBlt the form's image onto the Bitmap.
        BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, Me.ClientSize.Height, _
            me_hdc, 0, 0, SRCCOPY)
        me_gr.ReleaseHdc(me_hdc)
        bm_gr.ReleaseHdc(bm_hdc)

        ' Return the result.
        Return bm
        MainMenu1.Dispose()  ' Add this part of code into the function
    End Function