Click here to Skip to main content
16,015,072 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralSetting a form's location and size Pin
SerialHobbyist3-May-04 7:21
SerialHobbyist3-May-04 7:21 
GeneralRe: Setting a form's location and size Pin
Dave Kreskowiak3-May-04 9:36
mveDave Kreskowiak3-May-04 9:36 
GeneralRe: Setting a form's location and size Pin
SerialHobbyist4-May-04 3:08
SerialHobbyist4-May-04 3:08 
Questionhow to bind function results to a datagrid Pin
NADIA20003-May-04 0:33
NADIA20003-May-04 0:33 
AnswerRe: how to bind function results to a datagrid Pin
manos_p3-May-04 2:00
manos_p3-May-04 2:00 
GeneralRe: how to bind function results to a datagrid Pin
NADIA20003-May-04 18:52
NADIA20003-May-04 18:52 
GeneralRe: how to bind function results to a datagrid Pin
manos_p3-May-04 22:06
manos_p3-May-04 22:06 
QuestionTreeview, existing node? Pin
Andreas L3-May-04 0:10
Andreas L3-May-04 0:10 
Hi everyone!
(sorry for posting twice, but I posted in the wrong "area"(NET Framework) earlier)

New member and also new to VB.NET I'm planning to learn it, in order to creat nice user interfaces to databases.
The problem:
I have som code for moving nodes between treviews, and everything work fine as long as there already is one node in the destination treeview (we're talking drag and drop here).

However, I want to be able to check if there is NO destination-node, and in those cases run alternativ code.
I can only make it happen if I use OnErrorResumeNext statement in the sub, but I understand that is not a good way to handle exceptions like this.



Public Sub TreeView_DragDrop(ByVal sender As Object, _<br />
                                  ByVal e As DragEventArgs) _<br />
                                  Handles TreeView2.DragDrop, TreeView1.DragDrop, TreeView3.DragDrop<br />
<br />
        Dim NewNode As TreeNode<br />
        If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", False) Then<br />
            Dim pt As Point<br />
            Dim DestinationNode As TreeNode<br />
<br />
<br />
            pt = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))<br />
            DestinationNode = CType(sender, TreeView).GetNodeAt(pt)<br />
            <br />
<br />
            NewNode = CType(e.Data.GetData("System.Windows.Forms.TreeNode"), TreeNode)<br />
<br />
            On Error Resume Next 'don't want to use it here<br />
            If Len(DestinationNode.Text) < 1 Then 'error occur<br />
                'If Err.Number <> 0 Then MsgBox(Err.Description)<br />
                CType(sender, TreeView).Nodes.Add(NewNode.Clone)<br />
            Else<br />
                DestinationNode.Nodes.Add(NewNode.Clone)<br />
                DestinationNode.Expand()<br />
            End If<br />
            'Remove original node<br />
            NewNode.Remove()<br />
        End If<br />
    End Sub<br />


Thing is, if I don't drop the data on an existing node, "DestinationNode" has no value, but even if I try to check for Null-values an error occur, and the code stop running.

I want to be able to check for a valid value within DestinationNode, and make descision based on that, without causing an error. (IF there is no DestinationNode, THEN...)

How do a do this WITHOUT using On Error Resume Next?

Andreas
//Sweden
AnswerRe: Treeview, existing node? Pin
Dave Kreskowiak3-May-04 2:28
mveDave Kreskowiak3-May-04 2:28 
AnswerRe: Treeview, existing node? Pin
Dave Kreskowiak3-May-04 2:30
mveDave Kreskowiak3-May-04 2:30 
GeneralThanks! Pin
Andreas L3-May-04 2:50
Andreas L3-May-04 2:50 
GeneralPresenting Data using Flexgrid in VB.NET Pin
dpcodeproj2-May-04 23:53
dpcodeproj2-May-04 23:53 
Questionhow to write C++ code in VB7 Pin
Polywogs2-May-04 21:08
Polywogs2-May-04 21:08 
AnswerRe: how to write C++ code in VB7 Pin
Maxwell Chen2-May-04 21:21
Maxwell Chen2-May-04 21:21 
AnswerRe: how to write C++ code in VB7 Pin
Dave Kreskowiak3-May-04 2:19
mveDave Kreskowiak3-May-04 2:19 
GeneralRe: how to write C++ code in VB7 Pin
Polywogs8-May-04 21:20
Polywogs8-May-04 21:20 
GeneralCode to help me make Millionaire type game Pin
Anonymous2-May-04 20:07
Anonymous2-May-04 20:07 
GeneralRe: Code to help me make Millionaire type game Pin
vertigo_one2-May-04 20:22
vertigo_one2-May-04 20:22 
GeneralDatagrid Control Pin
Pugman8122-May-04 11:27
Pugman8122-May-04 11:27 
GeneralRe: Datagrid Control Pin
Tran Quoc Thang2-May-04 21:05
Tran Quoc Thang2-May-04 21:05 
GeneralProgrammatic Calendar Control Pin
_Tendo2-May-04 1:56
_Tendo2-May-04 1:56 
GeneralRe: Programmatic Calendar Control Pin
Dave Kreskowiak2-May-04 2:02
mveDave Kreskowiak2-May-04 2:02 
GeneralRe: Programmatic Calendar Control Pin
_Tendo2-May-04 18:50
_Tendo2-May-04 18:50 
GeneralRe: Programmatic Calendar Control Pin
Dave Kreskowiak3-May-04 2:13
mveDave Kreskowiak3-May-04 2:13 
GeneralVB COM DLL doesn't allow to update data from database using ADO Pin
vertigo_one1-May-04 14:53
vertigo_one1-May-04 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.