•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 427,202 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,274 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1120 | Replies: 2
![]() |
•
•
Join Date: Feb 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
this is my simple program and i need to save or write the info that i key in in a notepad and also have the function to displat the info in the notepad. Can any one help me?TQ
this is my simple program in VB. how can i write the info such as packet type and others in to a notepad and display record ?TQ
this is my simple program in VB. how can i write the info such as packet type and others in to a notepad and display record ?TQ
vb Syntax (Toggle Plain Text)
''General_Declaration of the form Dim sItem As String Dim sPacket As String Dim sSourceIP As String Dim temp As LinkList Dim Head As LinkList Dim First As LinkList 'Alwyas Points Starting of the List Dim i As Integer Private Sub Class_Initialize() Set pNext = gthing End Sub Private Sub Class_Terminate() Set pNext = Nothing End Sub '''Insert in to a node Private Sub InsertNode() 'Do While Not UCase(sItem) = "END" 'i = i + 1 'sItem = InputBox("Enter the Item", , "") 'sItem = Trim(sItem) sPacket = InputBox("Packet Type:", , "") sSourceIP = InputBox("Source IP Address:", , "") If Head Is Nothing Then Set temp = New LinkList temp.Protocol_Type = sPacket temp.Source_IP_Add = sSourceIP Set Head = temp Set First = Head Else Set temp = New LinkList temp.Protocol_Type = sPacket temp.Source_IP_Add = sSourceIP Set Head.pNext = temp Set Head = temp End If 'If UCase(sItem) = "END" Then Set Head.pNext = Nothing ' End If 'Loop End Sub '''''''--------------------------------------------------- 'Delete a Particular Node Private Sub DeleteNode() Dim sDelStr As String Dim d As LinkList Dim holdPrev As LinkList 'Hold Previous location while deleting Dim a Set temp = Nothing Set p = Nothing Set holPrev = Nothing Set d = First If d Is Nothing Then ' Text1.Text = "No Items In the List ' ! Insert Something 'before Delete !" a = MsgBox("NO MATCH FOUND. NO RECORD DELETED", vbInformation) Exit Sub End If sDelStr = InputBox("Please Enter Soure IP Address Of The Packet That You Want To Delete: ") sDelStr = UCase(sDelStr) Do While Not d Is Nothing If UCase(d.Source_IP_Add) = sDelStr Then a = MsgBox("Are you sure", vbOKCancel) If a = vbOK Then If holPrev Is Nothing Then Set First = d.pNext 'Call DisPlayNode Exit Sub End If Set d = holPrev Set d.pNext = temp.pNext If d.pNext Is Nothing Then 'if deleted node is last node Set Head = d End If a = MsgBox("RECORD DELETED", vbInformation) Exit Sub Else a = MsgBox("RECORD NOT DELETED", vbInformation) Exit Sub End If Else Set holPrev = d Set temp = d.pNext Set d = d.pNext End If Loop a = MsgBox("NO MATCH FOUND. NO RECORD DELETED", vbInformation) Set p = Nothing End Sub ''''''------------------------------------- 'Display all Nodes in the list Private Sub DisPlayNode() Dim p As LinkList Dim a Dim msg Set p = First If p Is Nothing Then a = MsgBox("NO RECORDS TO DISPLAY", vbInformation) Exit Sub End If msg = "ProType|SourceIPAdd" Do While Not p Is Nothing msg = msg & vbNewLine & p.Protocol_Type & vbTab & p.Source_IP_Add Set p = p.pNext Loop a = MsgBox(msg, vbInformation) Set p = Nothing End Sub ''''----------------------- Private Sub SearchNode() Dim d As LinkList Set d = First Dim sSearch As String Dim a sSearch = InputBox("Please Enter Source IP Address :") sSearch = UCase(sSearch) Do While Not d Is Nothing If UCase(d.Source_IP_Add) = sSearch Then a = MsgBox("RECORD FOUND" & vbNewLine & d.Protocol_Type & vbTab & d.Source_IP_Add, vbInformation) Exit Sub Else Set d = d.pNext End If Loop a = MsgBox("NO MATCH FOUND", vbInformation) End Sub '''''Cleanup all allocated memory Private Sub free() Set temp = Nothing Set Head = Nothing Set First = Nothing Set holdPrev = Nothing End Sub Private Sub cmdAdd_Click() Call InsertNode End Sub Private Sub cmdDelete_Click() Call DeleteNode End Sub Private Sub cmdDetect_Click() Call SearchNode End Sub Private Sub cmdDisplay_Click() Call DisPlayNode End Sub Private Sub cmdExit_Click() Call free Unload Me End Sub
Last edited by WolfPack : Mar 24th, 2008 at 11:20 am. Reason: Added code tags. Use them when you post code.
•
•
Join Date: Feb 2008
Location: Cebu, Philippines
Posts: 122
Reputation:
Rep Power: 1
Solved Threads: 19
i didnt read your code. but if writing on a notepad is your problem, i hope this helps.
vb Syntax (Toggle Plain Text)
Dim fso As New FileSystemObject Dim strm As TextStream Set strm = fso.OpenTextFile("c:\test.txt", ForWriting) strm.WriteLine ("String to write")
Last edited by cometburn : Mar 24th, 2008 at 9:34 pm.
Proud to be Philippine made...
•
•
Join Date: Apr 2008
Posts: 34
Reputation:
Rep Power: 1
Solved Threads: 4
The FSO option works great if you are writing to a text file, but it would still need to be opened.
Simple:
Better:
Simple:
Call Shell("NotePad.exe " & FileName, vbNormalFocus) Better:
Private Const SW_SHOWNORMAL As Long = 1 Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" _ (ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Call ShellExecute(Me.hWnd, "Open", "c:\TextFile.txt", vbNullString, vbNullString, SW_SHOWNORMAL)
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- fstream Tutorial (C++)
- How to read/write to an MS-Excel file?? (C++)
- Trouble reading and writing to a file (C++)
- Writing string to a file (Java)
- Need to send output to notepad (C++)
- get the file size? (Assembly)
- Need help with including C++ code in Word macro (C++)
- c++ compiling problem (C++)
- embPerl or PHP (Perl)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Msflexgrid data
- Next Thread: can or cannot?


Linear Mode