|
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
|
|
|
|
|
Look into Try/Catch blocks...
Try
[Some code that might fail goes here]
Catch [Grab exception type here]
[Code to handle exception goes here]
Catch [Grab a different exception type here]
[Code to handle a different exception goes here]
Finally
[Code that always runs no matter what happens goes here]
End Try
RageInTheMachine9532
|
|
|
|
|
You could also just check if DestinationNode is Nothing:
pt = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))
DestinationNode = CType(sender, TreeView).GetNodeAt(pt)
If DestinationNode Is Nothing Then
...
RageInTheMachine9532
|
|
|
|
|
The "IS NOTHING" worked great!
...and I learnd something about Null and Nothing!
Thanks Again!
|
|
|
|
|
I used a textbox control with the flexgrid to get data from user at runtime. I managed it programatically in Visual Basic 6.0. But I struck up in getting inputs from user by using flexgrid with in VB.NET.Can anyone help me out.
Thank You
with rgds,
prash
|
|
|
|
|
Is it possible to write C++ code directly into a form or module as a function or such?
|
|
|
|
|
I don't think so.
Maxwell Chen
|
|
|
|
|
No. It's has to be written into a seperate project and then you can reference it from your VB.NET app. The opposite is also true for C++. Mixing code languages can only be done at the project level. Your solution can have a project written in VB and another project written in C++. The two languages cannot appear in the same project.
RageInTheMachine9532
|
|
|
|
|
Thankyou, this seems to be the solution to my problem.
|
|
|
|
|
hey,
im wanting to make who wants to be milionaire type game, but i am only a beginner, does anyone have some suggestions, or previously made code for this type of thing that will help me in my process.
Thanku in advance.
|
|
|
|
|
Doesn't that game already exists in its PC Version?
Real Programmer isn't who just knows how to use a programming tool, Real Programmer is who knows how to write cool stuff in any language, 'cuz he/she/(it!!?) thinks like a machine .
|
|
|
|
|
I was working with a datagrid control connecting to a small 3 column access database. I have everything working but i have a save button and i want the save button to become active right when you edit something in on of the fields. I have accomplished this by using a timer and saying
if dataset.haschanges then<br />
btnsave.enable = true<br />
end if
But this only enables the button when you stop editing that cell i want the button to become active right when the editing begins. Thank you
|
|
|
|
|
Try this event!
dragrid1_edit
I don't remember exactly!
Do you want a loans with good services? Do you want to improve your finance?
This web site will be helpful
www.c-loans.com
You will love our services!
|
|
|
|
|
Am inserting a calender control programmatically into a web form but when I browse/ preview it & try to select, a date, the form gets 'reset' All controls apart from the buttons disappear It seems their is some hidden javascript that I can only see in the html, when browsing & not when developing.
What should I do to be able to submit selected dates to a database? (And not 'reset' the form)
|
|
|
|
|
This question belongs in the ASP.NET forum...
This sounds like a standard form that is never going to change. Why the need to insert a DateTime picker programatically? If the user is not supposed to see the control (or a group of controls), why not put it in a DIV or SPAN section, or a .NET Panel control, and keep it hidden until the user needs to see it?
RageInTheMachine9532
|
|
|
|
|
The entire form is being asembled programatically... client's wishes... The only controls that are 'declared' in asp.net are the containing asp panel and a hidden textbox. How do I insert a datetime picker programatically?
|
|
|
|
|
That's insane! Oh well, it's their money...
The way I've done it in the past is to put a PlaceHolder control on the page where you want the new controls to show up. This make it much easier to control the placement of generated controls. Next, when you put the new control in the PlaceHolder's Controls collection, you'll have to wire up the event handlers yourself. The basic code is something like this:
Dim myCalendar As New Calendar
myCalendar.ID = "myCalendar"
AddHandler [add any event handlers and function delegates here]
RageInTheMachine9532
|
|
|
|
|
Hi, I'm creating a COM Dll using VB6, I created simple functions to make an update on a database, but it doesn't work, I'm using an ASP Page that succesfully create the object but gives me errors when I try to insert or update data (Also I tried creating the object from other VB Application but didn't work either, 'weird' but when I use this code on a EXE it works, but I need this in a COM Dll).
VB Dll Code
Public Function Save()<br />
Dim Cn As New ADODB.Connection<br />
<br />
Cn.ConnectionTimeout = 100<br />
Cn.ConnectionString = "DBQ=test.mdb;" & _<br />
"DRIVER={Microsoft Access Driver (*.mdb)};" & _<br />
"DefaultDir=C:\My Docs\My Source Code\VB\ASP-COM Test;" & _<br />
"UID=admin; PWD=;"<br />
Cn.Mode = adModeReadWrite<br />
Cn.Open<br />
<br />
Cn.Execute "INSERT INTO tests (test_value) VALUES ('test3')"<br />
<br />
Cn.Close<br />
<br />
Save = True<br />
End Function
ASP page code
<%<br />
Dim iTest<br />
Set iTest = Server.CreateObject("TestProject.Test")<br />
<br />
Response.Write iTest.Save<br />
%>
Like this it returns this error
Error Type:<br />
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<br />
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.<br />
/xue2/index.asp, line 6
I also tried using a RecordSet Object but gives this error:
Error Type:<br />
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<br />
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.<br />
/xue2/index.asp, line 6
Thanks if anyone can help!
Vertigo
|
|
|
|
|
Hi
I faced similar problems with {Microsoft Access Driver (*.mdb)}; provider
try : OLEDB jet provider :
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin; Password=;"
and check http://www.connectionstrings.com [^]for more
|
|
|
|
|
Oh!, thank you for your answer, I tried before the same connection string with no positive results , but I found the solution , it was not big deal, it was nothing in the code, it was a problem with permissions in the IIS Configuration (Not using Anonymous Access [chosen by default when you create a virtual directory], the correct one was using the Integrated Windows Authentication.). I lost a complete day in a such thing but it happens .
Anyway, Thx for your help,
Vertigo
|
|
|
|
|
i have a string and i was wondering how i could grab each character of that string for example in c++ if
string="Hello World"
then
string[3]
would return a "l"
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
mid("Hello World",4,1)
returns "l"
note that in VB6 the first character index is 1 not 0 like C.
|
|
|
|
|
awsoem thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
You can also get them easily using the Chars property:
<br />
Dim s As String<br />
Dim i As Integer<br />
<br />
s = "one for the toad"<br />
For i = 0 To (s.Length - 1)<br />
Console.WriteLine(s.Chars(i))<br />
Next<br />
Note that most of the properties, etc. dealing with arrays in the BCL use zero-based indexing. It can be confusing switching back and forth between zero- and one-based indexing.
[EDIT] I misunderstood, and assumed the question was for VB .NET . I apologize. Back to the C# forums for this geek. [/EDIT]
Regards,
Jeff Varszegi
EEEP! An Extensible Expression Evaluation Package
|
|
|
|
|
could someone show me all the commands used for drawing in a picture box? (an example each would be helpful)?
is it possible to draw text in a picture box? preferabley without having to draw each pixel of each letter, u know like is there a command i could use? and could i make it centered?
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|