Click here to Skip to main content
15,923,689 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Browser Pin
Christian Graus15-Jun-06 23:20
protectorChristian Graus15-Jun-06 23:20 
GeneralRe: Browser Pin
Socheat.Net15-Jun-06 23:29
Socheat.Net15-Jun-06 23:29 
GeneralRe: Browser Pin
Dave Kreskowiak16-Jun-06 1:44
mveDave Kreskowiak16-Jun-06 1:44 
QuestionADODC QUESTION Pin
areon2515-Jun-06 21:11
areon2515-Jun-06 21:11 
AnswerRe: ADODC QUESTION Pin
Coding C#17-Aug-06 21:09
Coding C#17-Aug-06 21:09 
QuestionHelp Me to creat SQL Server Report ising SSRS 2005 Pin
asifhameed115-Jun-06 20:58
asifhameed115-Jun-06 20:58 
AnswerRe: Help Me to creat SQL Server Report ising SSRS 2005 Pin
Mekong River16-Jun-06 4:11
Mekong River16-Jun-06 4:11 
Questionnode diagram Pin
pavlaras1015-Jun-06 20:56
pavlaras1015-Jun-06 20:56 
hi all
its been a while since i've worked on a VB program and im currently facing difficulties with the following code.I'm trying to create a diagram with nodes which you can manipulate and enter data.So far the program creates the nodes with numbered text by dragging the node and moves them by right click them.I want to be able to go back and delete any node i want plus to be able to access the nodes(enter text,extra form with info that the user will give)
If you can provide pointers or links to example code or literature, it
would be appreciated.

just copy-paste the code on a class module and a form with an image control-index property must be set to 0

' [ Class1 ] ------------------------------------------------
Option Explicit

Public X As Long
Public Y As Long
Public Text As String
Public Handle As Image

Again Thanks
Public Kids As New Collection


Friend Sub RenderLines(Surface As Variant)
Dim Item As Class1
'Connect lines first, then do circles/text
For Each Item In Kids
Surface.Line (X, Y)-(Item.X, Item.Y), vbBlack
Item.RenderLines Surface
Next
End Sub

Friend Sub RenderText(Surface As Variant)
Dim Item As Class1
' draw the circles and text
Surface.Circle (X, Y), 500, vbBlack
Surface.CurrentX = X - Surface.TextWidth(Text) \ 2
Surface.CurrentY = Y - Surface.TextHeight(Text) \ 2
Surface.Print Text;

For Each Item In Kids
Item.RenderText Surface
Next
Handle.Move X - 500, Y - 500, 1000, 1000
End Sub

Public Function Locate(ByVal Index As Long) As Class1
Dim kid As Class1
Dim test As Class1
' reutrns the class whose handle has a certain Index
If Handle.Index = Index Then
Set Locate = Me
Else
For Each kid In Kids
Set test = kid.Locate(Index)
If Not test Is Nothing Then
Set Locate = test
Exit For
End If
Next
End If
End Function




' [ Form1 ] -------------------------------------------------------
Option Explicit
Private Node As Class1
Private Drawing As Boolean
Private StartX As Long, StartY As Long
Private OldX As Long, OldY As Long
Private StartNode As Class1


Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
DropIt Source, X, Y
End Sub

Private Sub Form_Load()
Me.FillStyle = vbFSSolid
Me.FillColor = vbWhite
Me.DrawWidth = 2
Set Node = NewItem(ScaleWidth \ 2, ScaleHeight \ 2, "Root", Image1(0))
End Sub

Private Sub Form_Paint()
Node.RenderLines Me
Node.RenderText Me
End Sub

Private Sub Image1_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Dim img As Image
Set img = Node.Locate(Index).Handle
DropIt Source, img.Left + X, img.Top + Y
End Sub

Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
'Select Draw Mode
Drawing = True
DrawMode = vbInvert
DrawStyle = vbDot
'Store start values
Set StartNode = Node.Locate(Index)
StartX = StartNode.X
StartY = StartNode.Y
OldX = X + StartNode.Handle.Left
OldY = Y + StartNode.Handle.Top
Else
OldX = X
OldY = Y
Node.Locate(Index).Handle.Drag vbBeginDrag
End If
End Sub

Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim XX As Long, YY As Long
If Drawing Then
' Convert Image click to Form coordinates
XX = X + StartNode.Handle.Left
YY = Y + StartNode.Handle.Top
'Erase old line
Line (StartX, StartY)-(OldX, OldY), vbBlack
'Draw new line
Line (StartX, StartY)-(XX, YY), vbBlack
OldX = XX
OldY = YY
End If
End Sub

Private Sub Image1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Drawing Then
Drawing = False
DrawMode = vbCopyPen
DrawStyle = vbSolid
' Create a new Image control, make it visible
Load Image1(Image1.Count)
Image1(Image1.Count - 1).Visible = True
' Add a new item to the node
Node.Locate(Index).Kids.Add NewItem(X + StartNode.Handle.Left, _
Y + StartNode.Handle.Top, CStr(Image1.Count - 1), _
Image1(Image1.Count - 1))
Refresh
End If
End Sub

Private Function NewItem(ByVal X As Long, ByVal Y As Long, Text As String, Handle As Image) As Class1
Set NewItem = New Class1
With NewItem
.X = X
.Y = Y
.Text = Text
Set .Handle = Handle
End With
End Function

Private Sub DropIt(Source As Image, ByVal X As Long, ByVal Y As Long)
Dim This As Class1
' Drops item
Set This = Node.Locate(Source.Index)
This.X = X - (OldX - 500)
This.Y = Y - (OldY - 500)
Source.Drag vbEndDrag
Refresh
End Sub

Questionvb.net 1.1 Pin
constantinejones15-Jun-06 19:39
constantinejones15-Jun-06 19:39 
AnswerRe: vb.net 1.1 Pin
Dave Kreskowiak16-Jun-06 1:39
mveDave Kreskowiak16-Jun-06 1:39 
AnswerRe: vb.net 1.1 Pin
Mekong River16-Jun-06 4:07
Mekong River16-Jun-06 4:07 
QuestionChaning The Browser Settings using a VB Activex Controls Pin
srinivasaRaoS15-Jun-06 18:59
srinivasaRaoS15-Jun-06 18:59 
AnswerRe: Chaning The Browser Settings using a VB Activex Controls Pin
Mekong River16-Jun-06 4:03
Mekong River16-Jun-06 4:03 
QuestionLoad multiple open file name in the list box Pin
Mekong River15-Jun-06 18:35
Mekong River15-Jun-06 18:35 
QuestionWord Automation using VB Net Pin
aakar15-Jun-06 15:22
aakar15-Jun-06 15:22 
AnswerRe: Word Automation using VB Net Pin
Mekong River16-Jun-06 4:00
Mekong River16-Jun-06 4:00 
Questionhow to create the MDB programmatically Pin
changeez15-Jun-06 11:53
changeez15-Jun-06 11:53 
AnswerRe: how to create the MDB programmatically Pin
Mekong River15-Jun-06 15:25
Mekong River15-Jun-06 15:25 
GeneralRe: how to create the MDB programmatically Pin
changeez16-Jun-06 1:04
changeez16-Jun-06 1:04 
GeneralRe: how to create the MDB programmatically Pin
Mekong River16-Jun-06 3:47
Mekong River16-Jun-06 3:47 
QuestionFrom Where Can I get VB.NET e-Book? Pin
Syed Ali Raza15-Jun-06 11:12
Syed Ali Raza15-Jun-06 11:12 
AnswerRe: From Where Can I get VB.NET e-Book? Pin
Mekong River15-Jun-06 15:31
Mekong River15-Jun-06 15:31 
GeneralRe: From Where Can I get VB.NET e-Book? Pin
Kevin McFarlane16-Jun-06 0:10
Kevin McFarlane16-Jun-06 0:10 
GeneralRe: From Where Can I get VB.NET e-Book? Pin
Mekong River16-Jun-06 0:18
Mekong River16-Jun-06 0:18 
QuestionDatagrid Column DataType convert Pin
WayneXu15-Jun-06 9:50
WayneXu15-Jun-06 9:50 

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.