Newbe question, What am I doing wrong



  • 1. Strange reference issue
    I posted this awhile back in the CF forum and got no answer, so I'm posting it here today in hopes that a broader group of developers might nudge me in the right direction. I'm getting a weird message with a reference to an assembly I created, have used in the past and then upgraded. Warning: The dependency 'ReplSet, Version=1.0.1951.254, Culture=neutral' in project 'CPN' cannot be copied to the run directory because it would overwrite the reference 'ReplSet, Version=1.0.1991.23034, Culture=neutral'. I've even done a search for all copies of ReplSet and none exist on my system with a version number ending in .254. I do have the .23034 version (which is the latest). Nor can I find any reference to .254 in the project -- except when I try to add .23034. How can I track down where this reference to .254 is coming from?
  • 2. double click on + for treenode
    Dear all, I have a question about TreeView elements. is it possible to differentate double click on TreeNode itself from double click on "+" of this TreeNode? Thanks in advance, Boni
  • 3. Convert windows SHFILEINFO to DotNet
    Need this: typedef struct _SHFILEINFO { HICON hIcon; int iIcon; DWORD dwAttributes; TCHAR szDisplayName[MAX_PATH]; TCHAR szTypeName[80]; } SHFILEINFO This is what I tried: Public Structure SHFILEINFO Public hIcon As IntPtr Public iIcon As Integer Public dwAttributes As Integer <MarshalAs(UnmanagedType.LPStr, SizeConst:=Kernel.MAX_PATH)> Public szDisplayName As String <MarshalAs(UnmanagedType.LPStr, SizeConst:=80)> Public szTypeName As String End Structure Kernel.MAX_PATH equals 260 But it doesn't appear to work. Does it look OK to you or do you know how to fix it. Thanks
  • 4. "Handles" Question
    This question is regarding the "Handles" part of a routine, for example: Handles Button1.Click On Form2 (a User Control) I have a button. Here's it's code: Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '... End Sub Ok, now on Form1, I have a Menu. One of the menu items needs to act like Button1 was clicked. I would like to add to the Handles section by adding: Handles Button1.Click, Menuitem1.Click This would work if the button and menuitem were on the same form. But they are on different forms. I get an error saying "Handles clause requires a WithEvents variable". How do I go about this? Thanks for your help! John

Newbe question, What am I doing wrong

Postby ken » Sun, 22 Jan 2006 12:04:38 GMT

I have two questions the first is: in the example below how can I call
an event from within a statement, such as replace Stop1 with cmdStop1
which is a button on my form?
My second question again deals with the example below. Shouldn't I see
the valve of " i" counting away in the  txtCount1 text box? I don't
see anything in the text box and would like to know what I'm doing
wrong. Thanks in advance for any and all help.

 Stop1 = 0
            For i As Integer = 1 To 10
                txtCount1.Text = i
                If Stop1 = 1 Then
                    Exit Do
                End If
            Next i
    End Sub

Re: Newbe question, What am I doing wrong

Postby Armin Zingler » Sun, 22 Jan 2006 12:17:36 GMT

"ken" < XXXX@XXXXX.COM > schrieb

You can not call an event. Either /raise/ an event or /handle/ it.

The textbox doesn't update because there is no time. There is not time
because the loop is running. If you update a control, the rectangle on the
screen is added to a list of invalid areas. The screen is (usually) not
updated immediatelly. As soon as there is time, Win sends a message to the
control (called WM_PAINT). Whenever the control receives this messages, it
paints itself. The message can not be handled before your sub returns.

To update the control immediatelly, call it's refresh method:
txtcount1.refresh. This /forces/ the immediate repaint of the control.

Be aware of a problem existing in WinXP (3rd paragraph):

This means, even in a tiny program, you are forced to use a second thread to
run the loop (or use application.doevents with all it's side-effects). A
work-around is to call the API function Peekmessage within the loop (in
addition to calling refresh).


Re: Newbe question, What am I doing wrong

Postby ken » Sun, 22 Jan 2006 12:37:52 GMT

Thank you for answering my questions. I suspected that loop was
happening to fast to update. Once again thanks.

Re: Newbe question, What am I doing wrong

Postby RGVubmlz » Sun, 22 Jan 2006 23:18:02 GMT

Dennis in Houston

Re: Newbe question, What am I doing wrong

Postby ken » Mon, 23 Jan 2006 09:34:23 GMT

Hi Dennis and thanks, What I was trying to say is how can I check if a
Button has been Clicked from within a Loop.

Re: Newbe question, What am I doing wrong

Postby RGVubmlz » Tue, 24 Jan 2006 03:48:01 GMT

For one thing, the button Click event won't fire until your loop finishes 
unless you have a "DoEvents" statement within your loop or the loop is 
executing on a NON-UI thread.

If you put a "DoEVents" statement withing your loop, you can use a boolean 
variable which scoped for access both in the button click event handler and 
the loop.  Set the variable to False before the loop starts then set it to 
true in the button click event handler and check it after the DoEvents 
Statement in your loop.

Hope this helps.
Dennis in Houston

Similar Threads:

1.What am I doing wrong??

Here is what I am trying:

\Application Data", _
"C:\Documents and Settings\" & Environment.UserName & "\Application
Data\Adobe", True)
        MessageBox.Show("Done Resetting Application Data, Press OK to
Continue and reset Local Settings data", "Backup in progress...",
MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
\Local Settings", _
"C:\Documents and Settings\" & Environment.UserName & "\Local Settings
\Application Data\Adobe", True)
        MessageBox.Show("Done Resetting Local Settings data, Press OK
to Continue.", "Backup in progress...", MessageBoxButtons.OK,

I get the error that: \\server\all\sets\Application Data  is not
found, but it is there, and inside that folder I want to copy a folder
to c:\doc and set\user\application data\adobe

Also, will this work like this, one statement after another to do two


2.What am I doing wrong - Trying to update

I have enclosed the sample code that I created.  I want to read in employee 
data, and modify a few fields.  I have tried to globally declare the objects 
that I need but I still am having problems.  I want to update in a seperate 
subroutine and seem to have problems.  HELP please.

Public Class Form1

    Inherits System.Windows.Forms.Form
    Public cn As OleDb.OleDbConnection
    Public ds As DataSet
    Public da As OleDb.OleDbDataAdapter
    Public rowEmployee As DataRow

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

            Dim strConn As String
            strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data 

            Dim cn As New OleDb.OleDbConnection(strConn)

            Dim strSQL As String
            strSQL = "SELECT EmployeeID, FirstName, LastName, Address, City, 
Region, " & _
                "PostalCode from Employees ORDER BY LastName, FirstName"

            Dim da = New OleDb.OleDbDataAdapter(strSQL, strConn)
            Dim ds As New DataSet

            da.Fill(ds, "Employees")

            Dim tbl As DataTable = ds.Tables(0)

            'rowEmployee = New DataRow
            rowEmployee = tbl.Rows(0)
            txtFirstName.Text = rowEmployee("FirstName")
            txtLastName.Text = rowEmployee("LastName")
            txtAddress.Text = rowEmployee("Address")

        Catch ex As Exception
            MessageBox.Show(ex.Message & " :: " & ex.Source)
        End Try
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles btnUpdate.Click
            rowEmployee("LastName") = txtLastName.Text

        Catch ex As Exception

            MessageBox.Show(ex.Message & " :: " & ex.Source)

        End Try

    End Sub
End Class

When it runs I get the following error:

"Object reference not set to an instance of an object."

on the             da.Update(ds)       line in the btnUpdate_Click routine.




3.Project build problem - what am I doing wrong?

I have a program that needs to access a prewritten external data file
that is supplied with the program. I want to place this data file in

In the program's setup project I've done: Add Special Folder | User's
Application Data File, then within this created a folder called
MyProgramFolder, then Add File and pointed to a copy of my external
data file, which duly appears in the folder contents (EXCEPT that it
has a wavy line underneath!)

But unfortunately the resulting setup program does not install the
external data file where it should - in fact as far as I can see it
does not install it at all anywhere on the target PC.

Cany anyone advise what I'm doing wrong please? The fact that the file
entry has a wavy line underneath is presumably indicative of an error
but what's the cause and how do I fix it?


4.Table doesn't update - What am I doing wrong?

I have a form that has three textboxes on.  I want to be able to modify the 
FirstName, LastName, and Address

Here is the code to load the data
   Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load

        Dim strSQL As String = "Select * from Contact where sysid = '" & 
g_sysID & "'"
        DB = New SqlClient.SqlDataAdapter(strSQL, CN)
        DB.Fill(ES, "Contact")

        If ES.Tables("Contact").Rows.Count > 0 Then
            txtAddress.Text = 
            txtFirst_Name.Text = 
            txtLast_Name.Text = 
        End If

    End Sub
Here is the code to update the table
   Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles btnUpdate.Click

            es.Tables(0).Rows(0).Item("First_Name") = txtFirst_Name.Text
            es.Tables(0).Rows(0).Item("Last_Name") = txtLast_Name.Text
            es.Tables(0).Rows(0).Item("con1_02_03") = txtAddress.Text
            DB.Update(ES, "Contact")

        Catch ex As Exception


        End Try

    End Sub
Why doesn't the table update?  Can anyone give me an explanation and also if 
I need to change code, please tell me where to put the modifications?



5.Programatically getting a RichTextBox to scroll - What Am I doing Wrong

Ive been working on this since yesterday and its bugging me. Although the
event is firing, The box does not scroll. Can anyone see what Im doing
wrong. I suspect it is stupidly simple.


SubClass RichtextBox in order to fire the OnVScroll Event

Public Class MyRichTextBox

Inherits RichTextBox

Public Sub PerformVScroll()


End Sub

End Class

- This button invokes the PerformVScroll -

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PerformVscroll.Click


End Sub

- THis confirms that the event has been raised -

Private Sub handleScroll(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RTB.VScroll

Console.WriteLine("Handling scroll")

End Sub

Regards - One Handed Man

Author : Fish .NET & Keep .NET
This posting is provided "AS IS" with no warranties,
and confers no rights.

6. What am I doing wrong?

7. What am i doing wrong?

8. What am I doing wrong?

Return to VB.NET


Who is online

Users browsing this forum: No registered users and 85 guest