Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Need help with Comboboxes

$
0
0
First off, thank you very much in advance.

Here is a simple version of the program I am trying to build.

Name:  IyFmAuf.jpg
Views: 78
Size:  38.0 KB, Name:  Nh2b2Hh.jpg
Views: 89
Size:  47.2 KB

My code is:


Public Class Form1
Public Function Encrypt(s As String, v As Long) As String
Dim total As String
Dim tmp As String
For i = 1 To Len(s)
tmp = Mid(s, i, 1)
tmp = Asc(tmp) + v
tmp = Chr(tmp)
total = total & tmp
Next i
Encrypt = total

'This hides the folder name
End Function

Public Function Decrypt(s As String, v As Long) As String
Dim total As String
Dim tmp As String
For i = 1 To Len(s)
tmp = Mid(s, i, 1)
tmp = Asc(tmp) - v
tmp = Chr(tmp)
total = total & tmp
Next i
Decrypt = total

'This shows the folder name
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.Items.AddRange(System.IO.Directory.GetLogicalDrives)
ComboBox2.Items.AddRange(System.IO.Directory.GetLogicalDrives)
'Adds the drive locations to the Comboboxes

ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim encName As String = (ComboBox1.SelectedItem.ToString & "test\") & Encrypt(TextBox1.Text, 1)
'Selects the path for the folder and file to create

If (Not System.IO.Directory.Exists(encName)) Then
System.IO.Directory.CreateDirectory(encName)
End If
'Creates the folder

Dim objwriter As New System.IO.StreamWriter(encName & "\text.txt")
objwriter.Write("hello world")
objwriter.Close()
'Creates the text file
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim objreader As New System.IO.StreamReader(ComboBox2.SelectedItem.ToString & "test\" & ComboBox3.SelectedItem.ToString & ("\text.txt"))
TextBox2.Text = objreader.ReadToEnd
objreader.Close()
'Reads the file based on the selected Name from Combobox2
End Sub
End Class


So my question is how do I make it so that in the Combobox3 reads the names of the folders in

(ComboBox2.SelectedItem.ToString & "test\")

and

decrypt(each item, 1), and remove (ComboBox2.SelectedItem.ToString & "test\")

So that instead of having in the combobox;

- C:\test\uftu2
- C:\test\uftu3
- C:\test\uftu4
- C:\test\uftu5

I would like to get;

- test1
- test2
- test3
- test4

I appologise for the poor explaining and thank you very much in advance.
Attached Images
  

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>