Articles

Metasploit Framework Windows Tutorial
Remote Desktop Connection
Windows Processes That May Be Dangerous
How-To use NetCat a Tutorial
Common Linux Commands
Common Ports
Netcat Commands
HTTP Response Codes
War-Google Hack Terms
Wardriving
Avoiding Social Engineering and Phishing Attacks
Intrusion Detection on Linux
Linux Intrusion Detection
Penetration Testing Guide
Penetration Testing Tools
Social Engineering Fundamentals, Part I: Hacker Tactics
Social engineering (computer security)
The Psychology of Social Engineering

The Archives

General GSO
GovernmentSecurity.org News & Suggestions
In The News
Open Topic
General Security Information
Trash Can
Exploit & Vulnerability Mailing List Archives
Trial Member Forum
Product and Program Reviews GSO Tutorials
System Security
Windows Systems
Beginners Section
Linux & Unix Systems
File Downloads
Exploit Research & Discussion Trojan & Virus Errata
Networking Security / Firewall / IDS / VPN / Routers
System Hardening
E-Mail Security
Wifi Security
Trial Member Uploads
Upload discovered Trojans & Mal ware
GSO Programming Section
C , C++ , VC++
Visual Basic.NET
Perl /CGI
Java/Javascript
PHP/XML/ASP/HTML
Assembly + Other
The Cork Board
Network Security Consultant Directory
Network Security Jobs
The Archives
Encryption Information
General Network Security
Internet Anonymity
HTTP Protocol Security
Linux Security
MS IIS Information
Exploit Articles
Programming / Tool Design
GSO Software Projects
Public Downloads
Microsoft Security Questions and Papers

Full Version: Nested For Next
binary_hashes
hi,


I am new to VB so here is my question:

I wana make a program to generate output in Listbox like
----------------
1
12
123
1234
12345
-----------------

Using the nested for next loop

Thankx rolleyes.gif

wiNGCom
why a nested for loop? Is this a requirement? smile.gif I'm probably missing some parameter then.

CODE

Option Explicit

Private Const mLoop As Integer = 5

Private mValue As String
Private mCount As Long

Private Sub Command1_Click()
   Dim i As Integer
   
   For i = 0 To mLoop
       If Trim(mValue) = "" Then
           mValue = "1"
           mCount = 1
       Else
           mValue = mValue & CStr(mCount + 1)
           mCount = mCount + 1
       End If
       List1.AddItem (mValue)
   Next i
End Sub
binary_hashes
Actually i want a nested loop(requirement), not any conditional Statement like IF then else"

To my thinking there is something to do with Left, Len functions but i am unable to get logic.
belgther
well, I have another method which is inspired from wingcom's method, but doesn't use conditions:

CODE

Option Explicit

Private Const mLoop As Integer = 5

Private mValue As String

Private Sub Command1_Click()
  Dim i As Integer
  mValue = "1"
  List1.AddItem (mValue)

  For i = 2 To mLoop
      mValue = mValue & CStr(i)
      List1.AddItem (mValue)
  Next i
End Sub


nested loop example(because you wanted it so): smile.gif

CODE

Option Explicit

Private Const mLoop As Integer = 5

Private mValue As String

Private Sub Command1_Click()
  Dim i As Integer
  Dim j As Integer

  For i = 1 To mLoop
  mValue=""

      for j=1 to i
      mValue = mValue & CStr(j)
      next j

  List1.AddItem (mValue)
  Next i

End Sub
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.