See if this helps.
Dim fontName As FontFamily = TextBox1.Font.FontFamily '// Get the Current Font Name used.
TextBox1.Font = New Font(fontName, TrackBar1.Value) '// Set Font Name and Size.
See if this helps.
Dim fontName As FontFamily = TextBox1.Font.FontFamily '// Get the Current Font Name used.
TextBox1.Font = New Font(fontName, TrackBar1.Value) '// Set Font Name and Size.
For x As Integer = 1 To CInt(UserInputTextbox.Text)
For Each ctl As Control In Me.Controls '// Loop thru all Controls on Form.
If TypeOf (ctl) Is Panel Then '// Locate Panels.
If ctl.Name = "P" & x.ToString Then
ctl.Enabled = True
Exit For
End If
End If
Next
Next
Dim myCoolOpenFileDialog As New OpenFileDialog
If myCoolOpenFileDialog.ShowDialog = DialogResult.OK Then
'// Load File from Full Path.
MsgBox(myCoolOpenFileDialog.FileName)
End If
Not quite understanding your question.
..If you need to have a TextBox get reversed as the File does, try this quick fix.
Change this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myFile As String = "C:\test.txt" '// your File.
If IO.File.Exists(myFile) Then '// Check if File.Exists.
MsgBox(reverseFileContent(myFile)) '// Display Result.
IO.File.WriteAllText(myFile, reverseFileContent(myFile)) '// Save Reversed File.
Else : MsgBox("File Does Not Exist.")
End If
End Sub
Function reverseFileContent(ByVal mySelectedFile As String) As String
Dim arFileLines() As String = IO.File.ReadAllLines(mySelectedFile) '// Load each line as a String Array.
Dim arWords() As String = Nothing '// used to Split. each line into Words.
Dim sChar As String = Nothing '// used to get/set last char of word if not a Letter.
To:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = reverseFileContent(TextBox1.Lines)
End Sub
Function reverseFileContent(ByVal arFileLines() As String) As String
'// Load each TextBox Line as a String Array.
Dim arWords() As String = Nothing '// used to Split. each line into Words.
Dim sChar As String = Nothing '// used to get/set last char of word if not a Letter.
yeH syug!
woH nac I trevni ro( esrever, revetahw) a gnirts, tub gnisrever hcae drow?
ekiL:
sihT si a gnirts.
tuptuO:This is a string.
dna ton:string. a is This
oslA, woh nac I od ti ot a eritne elif?sknahT ni ecnavda!
teL em wonk fi siht spleh.:D
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myFile As String = "C:\test.txt" '// your File.
If IO.File.Exists(myFile) Then '// Check if File.Exists.
MsgBox(reverseFileContent(myFile)) '// Display Result.
IO.File.WriteAllText(myFile, reverseFileContent(myFile)) '// Save Reversed File.
Else : MsgBox("File Does Not Exist.")
End If
End Sub
Function reverseFileContent(ByVal mySelectedFile As String) As String
Dim arFileLines() As String = IO.File.ReadAllLines(mySelectedFile) '// Load each line as a String Array.
Dim arWords() As String = Nothing '// used to Split. each line into Words.
Dim sChar As String = Nothing '// used to get/set last char of word if not a Letter.
Dim sTemp As String = Nothing '// used to save Reversed Lines.
For iFileLineNumber As Integer = 0 To arFileLines.Length - 1 '// Loop thru all Lines.
If arFileLines(iFileLineNumber).Contains(" "c) Then '// Check if Current Line Contains. a "space".
arWords = arFileLines(iFileLineNumber).Split(" "c) '// Split. Line into Words by "space".
For iWord As Integer = 0 To arWords.Length - 1 '// Loop thru all Words.
If Not arWords(iWord) = Nothing Then '// check if Word is not Nothing, since Words get Split. by " ".
If Char.IsLetter(CChar(arWords(iWord).Substring(arWords(iWord).Length - 1, 1))) Then '// …
See if this helps.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://google.com/")
End Sub
Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
If WebBrowser1.Url.AbsoluteUri = "http://www.google.com/" Then
WebBrowser1.Navigate(WebBrowser1.Url.AbsoluteUri & "?pass=123456")
End If
Me.Text = WebBrowser1.Url.AbsoluteUri
End Sub
End Class
Please post code that causes this new issue.
Are you asking to Re-size the Image it's self OR change the SizeMode/BackgroundImageLayout of the PictureBox, depending if the image is larger than the PictureBox.Size?
See if this helps.
Public Class Form1
Private myImagesFolder As String = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myImagesFolder = "C:\TEMP\" '// your Folder Path.
For RELREF As Integer = 1 To 30 '// Loop from 1 to 30.
For Each pb As Control In Me.Controls '// Loop thru all Controls in Form1.
If TypeOf (pb) Is PictureBox AndAlso pb.Name = "PictureBox" & RELREF Then '// check if Control is PictureBox and Name is "=" to...
For Each lbl As Control In Me.Controls '// Loop thru all Controls Again to locate Labels.
If TypeOf (lbl) Is Label AndAlso lbl.Name = "Label" & RELREF Then '// check if Control is Label and Name is "=" to...
pb.BackgroundImage = Image.FromFile(myImagesFolder & lbl.Text) '// Add Image.
Exit For '// Exit Loop once locating Label that Name .EndsWith # as PictureBox.
End If
Next
Exit For '// Exit Loop once locating PictureBox that Name .EndsWith # as RELREF.
End If
Next
Next
End Sub
End Class
See if this helps.
Option 1.
Select Case MsgBox("Are you sure to DELETE?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, "WARNING")
Case MsgBoxResult.Yes
MsgBox("YES Clicked.")
Case MsgBoxResult.No
MsgBox("NO Clicked.")
End Select
Option 2.
If MsgBox("Are you sure to DELETE?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, "WARNING") = MsgBoxResult.Yes Then
MsgBox("YES Clicked.")
Else
MsgBox("NO Clicked.")
End If
Option 3.
Select Case MessageBox.Show("Are you sure to DELETE?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2)
Case DialogResult.Yes
MsgBox("YES Clicked.")
Case DialogResult.No
MsgBox("NO Clicked.")
End Select
Option 3 can also be used in a If/End If Statement and the selection of which button to be highlighted can also be changed.
See if this helps.
2 Buttons.
Public Class Form1
Private LocationArray() As String = {"5,40,50,100", "75,125,30,45", "150,90,50,75", "75,40,180,25", "5,200,250,25"}
Private penBlack As New Pen(Color.Black, 3) '// Default Color.
Private penRed As New Pen(Color.Red, 3) '// Selection Color.
Private arTemp() As String = Nothing '// .Split Locations Strings into(location.X, location.Y, width, height)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Visible = True
drawRectangles()
End Sub
'// Draw ALL Rectangles as Default Color.
Private Sub drawRectangles()
Dim myGraphics As Graphics = Me.CreateGraphics
For Each rect As String In LocationArray '// Loop thru all Locations Strings.
arTemp = rect.Split(",") '// Split into 4 Arrays.
myGraphics.DrawRectangle(penBlack, CInt(arTemp(0)), CInt(arTemp(1)), CInt(arTemp(2)), CInt(arTemp(3))) '// draw Rectangle.
Next
End Sub
'// Draw ALL Rectangles as Default Color AndAlso Draw the SELECTED Rectangle as Selection Color.
Private Sub drawSelectedRectangle(ByVal RectangleLocationAndSizeFromStringArray As String)
drawRectangles() '// Redraw all Rectangles to set ALL to Default Color.
Dim myGraphics As Graphics = Me.CreateGraphics
arTemp = LocationArray(RectangleLocationAndSizeFromStringArray).Split(",") '// Split into 4 Arrays.
'// Redraw a Selected Rectangle, with the Selection Color.
myGraphics.DrawRectangle(penRed, CInt(arTemp(0)), CInt(arTemp(1)), CInt(arTemp(2)), CInt(arTemp(3))) '// draw Rectangle.
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
drawSelectedRectangle(3) '// 4th in LocationArray().
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
drawSelectedRectangle(1) '// 2nd in LocationArray().
End Sub
End Class
If you just need to extract data from a webpage, see if this helps to extract the "Tags" from the "Tag Cloud" of this page.
New Project, 1 ListBox, 1 WebBrowser.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://www.daniweb.com/forums/thread335473.html")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
getItems(WebBrowser1.Document.Body.InnerHtml.Split(vbCrLf), ListBox1)
End Sub
Private Sub getItems(ByVal arLines() As String, ByVal selectedListBox As ListBox)
selectedListBox.Items.Clear() '// Clear in case the webpage reloads.
For i As Integer = 0 To arLines.Length - 1 '// Loop thru all Strings in the Array.
If arLines(i).Contains("<DIV class=tagcloud>") Then '// Locate the String that .Contains...
Dim arTemp() As String = arLines(i).Split(">") '// .Split the entire String into Arrays.
For Each itm As String In arTemp '// Loop thru all Strings in the Array.
If itm.EndsWith("</A") Then '// check if String .EndsWith("</A")
itm = itm.Replace("</A", "") '// Remove the HTML Code from String.
selectedListBox.Items.Add(itm) '// add Tag Name to ListBox.
End If
Next
Exit For '// Exit the Loop.
End If
Next
End Sub
End Class
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
If e.KeyCode = Keys.Return Then
keyPressed()
End If
End Sub
Sub keyPressed()
MsgBox("Enter key Pressed.")
End Sub
Also, see if this helps.
Public Class Form1
Private myFile As String = "C:\test.txt" '// your File to Load/Edit if needed/Save.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(myFile) Then '// check if File Exists.
Dim arTemp() As String = IO.File.ReadAllLines(myFile) '// Load File Lines in a String Array.
Dim sTemp As String = Nothing '// String used to keep only selected File lines.
Dim bKeepFileLines As String = True '// determine if worth keeping the remaining File Lines or Not.
For Each fileLine As String In arTemp '// Loop thru all File Lines in the String Array.
If fileLine.StartsWith("****") Then bKeepFileLines = False '// check if line.StartsWith... and set to False NOT to keep the File Lines.
If fileLine.StartsWith(";") Then bKeepFileLines = True '// once Locating the ";", it sets to Keep the remaining File Lines.
If bKeepFileLines = True Then '// if set to True, keep the File Lines.
If Not sTemp = Nothing Then '// check if Not Empty, add a Line Break and the Line Content.
sTemp &= vbNewLine & fileLine
Else '// add only the Line Content.
sTemp = fileLine
End If
End If
Next
IO.File.WriteAllText(myFile, sTemp) '// Save File back: IO.File.WriteAllText(File Name, File Content to Save)
MsgBox("File Edited and Saved.", MsgBoxStyle.Information) '// Display confirmation that File has been modified and Saved.
Else
MsgBox("File Does Not Exist.", MsgBoxStyle.Critical) '// Display confirmation if File Does Not Exist.
End If
End Sub
End Class
If by "slaughtering a Giraffe", you mean poke it's eyes out, then I'm out of luck. Too short and I only have a step ladder.:D
Although, one time, I was in a tree, hiding behind a leaf, and had a 50 foot ladder to poke a giraffe's eyes with:D, but that another story and probably the wrong forum for.
..The last link I have posted, was to give you an idea on how to modify the WebBrowser's content.
First you would have to replace all the similar names with your own, then probably save the content to a file somehow, and load that file with the File's location and the "#some name".
You might also have to replace links within the file saved, for example, a link that is <a href="/somepage/etc.">, might have to be saved w/the URL of the page you are currently viewing, as: <a href="http://www.somesite.com/somepage/etc.">.
As mentioned previously, I have not done much/if any DomDocument editing, but the info I have provided so far for this thread should give you a good start.
See if this helps.
1 TextBox (MultiLine), 1 Button.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = getUrlPageContent("http://www.daniweb.com/forums/post1433319.html")
End Sub
Function getUrlPageContent(ByVal url As String) As String
Try
Dim connect As Net.HttpWebResponse = CType(Net.HttpWebRequest.Create(url).GetResponse, Net.HttpWebResponse) '// connect.
Dim content As IO.Stream = connect.GetResponseStream()
Dim reader As New IO.StreamReader(content)
Dim htmlContent As String = reader.ReadToEnd
reader.Close() : content.Close() : connect.Close()
Return htmlContent
Catch ex As Exception
MsgBox("There was a connection problem...", MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
End Class
Hopefully these "Html elements" have "names".
For instance, when viewing a webpage's HTML source code, and you locate something similar to:
<div class="shade"> <div class="right"> <a href="/forums/post1433269.html#post1433269" id="postcount1433269" [B]name="4"[/B]>Permalink</a> </div> 1 Minute Ago
..you have to locate the "name=..." part of the HTML and simply add a "#" and the name, just following the original link of the page.
Example:
http://www.daniweb.com/forums/thread335165.html#4
This usually targets an area of the webpage and scrolls it to the very top of the browser.
If you cannot locate the "name" of something and/or would like to "center" the content of the webpage in the WebBrowser instead of scrolling it to the top, you will have to modify the WebBrowser "DomDocument" and insert "names" in certain locations of the page to use and target.
I personally have not done much, if any DomDocument webpage editing, but hopefully this link might give you an idea on how to get started.
I'm not quite clear on your question.
..Are you trying to login a website?
..Scroll to a section in the webpage that has been loaded in your vb.net WebBrowser?
..OR just extract the data from a certain section when an item is checked in your CheckedListBox?
Btw, if you are guilty for joining DaniWeb just to ask a question or two, then I am guilty for joining DaniWeb to answer a question, or two.:D
If your INI File content is exactly as you have posted, see if this helps.
Public Class Form1
Private myFile As String = "C:\test.txt" '// your File.
Private arlFileInfo As New ArrayList '// ArrayList to store Information for each Entry.
Dim arTemp() As String = Nothing '// String Array to use as needed.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(myFile) Then '// check if File Exists.
arTemp = IO.File.ReadAllLines(myFile) '// Read each Line into a String Array.
For i As Integer = 0 To arTemp.Length - 1 '// Loop thru all Lines.
If arTemp(i).StartsWith("[Entry") Then '// If Line .StartsWith("[Entry").
'// Add 1st, 2nd, and 3rd Lines following the Line that .StartsWith("[Entry") as New Item to your Array List.
arlFileInfo.Add(arTemp(i + 1) & "~" & arTemp(i + 2) & "~" & arTemp(i + 3)) '// "~" used to .Split Item when extracting data from Item.
End If
Next
End If
'//======== DISPLAY RESULT FOR SECOND ENTRY =======
arTemp = arlFileInfo(1).ToString.Split("~") '// split Item 2 by the "~" char.
'// Display result.
MsgBox(arTemp(0) & vbNewLine & arTemp(1) & vbNewLine & arTemp(2), MsgBoxStyle.Information) '======\\
'//======== DISPLAY RESULT FOR FIRST ENTRY =======
arTemp = arlFileInfo(0).ToString.Split("~") '// split Item 1 by the "~" char.
'// Display result.
MsgBox(arTemp(0) & vbNewLine & arTemp(1) & vbNewLine & arTemp(2), MsgBoxStyle.Information) '======\\
End Sub
End Class
A simple way is to "use a TabControl".
Try this in a New Project.
Add a Panel, place a TabControl inside the Panel, possibly at .Location(0,0), and add 2 Buttons to the Form.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TabControl1.Location = New Point(TabControl1.Location.X, -21) '// move TabControl1 to a .Location.Y where tabs are not visible.
Button1.Text = "Previous" : Button2.Text = "Next"
End Sub
'// Previous.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not TabControl1.SelectedIndex = 0 Then TabControl1.SelectedIndex -= 1 '// Scroll Back thru tabs.
End Sub
'// Next.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Not TabControl1.SelectedIndex = TabControl1.TabPages.Count - 1 Then TabControl1.SelectedIndex += 1 '// Scroll Forward thru tabs.
End Sub
End Class
When the Form Loads, it moves the TabControl1 up. Doing so, the tabs are not visible.
..Having it moved up by code, allows you to edit the tabs as needed while working in .Designer.
A Complex way is to design your entire application to use Dynamic Controls and Add/Remove them as needed.
Let me know if this helps.:)
See if this helps.
'// Save Image as .txt File.
PictureBox1.Image.Save("C:/test.txt", Imaging.ImageFormat.Png)
'// Load Image from .txt File.
PictureBox1.Image = Image.FromFile("C:/test.txt")
See if this helps.
Public Class Form1
Private myCoolFile As String = "C:\test.txt" '// your file.
Private myCoolFileLines() As String = Nothing '// String Array to read File Lines into.
Private sTemp As String = Nothing '// temp String to be used as needed.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(myCoolFile) Then '// check if File Exists.
myCoolFileLines = IO.File.ReadAllLines(myCoolFile) '// load each line from your File as a String Array.
TextBox1.Text = readFileLine(0) '// line 1 returned from Function.
TextBox2.Text = readFileLine(1) '// line 2 returned from Function.
End If
End Sub
Function readFileLine(ByVal selectedLine As Integer) As String
'// get .Substring of selected line, starting from the "=".
sTemp = myCoolFileLines(selectedLine).Substring(myCoolFileLines(selectedLine).IndexOf("=") + 1)
Return sTemp '// Return .Substring.
End Function
End Class
I downloaded the project, reviewed the files, and all that "non english" makes my head spin trying to figure out what is what.:(
Sorry, but I do not have a solution to provide. Good luck.
Hello, codeorder. Thank you for your answer.
I've been looking at your code and, to be honest, I'm really not getting this to work because it writes to the file but when I close the application and then open it again, it doesn't load the data stored on it.
Also, can't this be done according to the logic I've been using with lists?
Or, at least can I "incorporate" this id into my code?
Once again, thank you for your answer.
If you want to load the data stored in the file when loading your application again with the code sample I have provided, simply select any Client from the ComboBox.
About having it "done according to the logic I've been using with lists" and/or ""incorporate" this id into my code", please post the entire code you have done so far, possibly with some comments.
I previously have tried to figure out how to provide a solution using your code examples, but due to your code constantly changing and only having bits and pieces of code here and there, I was not able to figure out what is what and how it all connects.
See if this helps.
New Project and No previous Clients.txt File.
'//------ Pre-requisites: 4 TextBoxes (ID/Name/Address/Phone)
'------------------------ 2 Buttons (Add Client/Clear Fields)
'------------------------ 1 ComboBox (Load Client Information) -------\\
Public Class Form1
Private myClientsFile As String = "C:\Users\codeorder\Desktop\Clients.txt" '// your File to Load / Save.
Private arlClients As New ArrayList '// keeps all Clients Information.
Private iClientID As Integer = 1 '// ID #.
'//--------- Save File. --------------\\
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim myWriter As New IO.StreamWriter(myClientsFile)
For Each itm As String In arlClients '// Loop thru all Clients in the ArrayList.
myWriter.WriteLine(itm) '// write each Client on a new line.
Next
myWriter.Close()
End Sub
'//--------- Load File if Exists. --------------\\
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(myClientsFile) Then '// check if File Exists.
arlClients.AddRange(IO.File.ReadAllLines(myClientsFile)) '// Load your Clients File in the ArrayList.
Dim arTemp() As String = Nothing '// String Array to .Split the File Lines into Arrays.
For Each itm As String In arlClients '// Loop thru all Clients that were added to the ArrayList.
arTemp = itm.Split("~") '// .Split Line by your selected char.
'// check if String Array 1 is greater than the last added ID, if so, change the iClientID.
If CInt(arTemp(0)) > iClientID Then iClientID = CInt(arTemp(0))
ComboBox1.Items.Add(arTemp(1)) '// add only Client Name to ComboBox.
Next
iClientID += 1 '// increase for Next available ID.
Else '//-------- TESTING PURPOSES TO DETERMINE TEXTBOXES.
TextBox2.Text = "name" : TextBox3.Text …
Since you mentioned that you have a File with just one line as my "test.txt" File,
1/2/3/4/
..see if this helps.
Dim myFile As String = "C:\test.txt" '// your File.
If IO.File.Exists(myFile) Then '// check if File Exists.
'// read Text from File and Split into Arrays by the "/" char.
Dim z() As String = IO.File.ReadAllText(myFile).Split("/")
TextBox1.Text = z(0) '// Array 1.
TextBox2.Text = z(1) '// Array 2.
TextBox3.Text = z(2) '// Array 3.
TextBox4.Text = z(3) '// Array 4.
End If
See if this helps.
'//----- Pre-requisites: 4 TextBoxes. -------\\
Dim arTemp() As String = {"text 1", "text 2", "text 3", "text 4"}'// your Array.
TextBox1.Text = arTemp(0)
TextBox2.Text = arTemp(1)
TextBox3.Text = arTemp(2)
TextBox4.Text = arTemp(3)
See if this helps.
'//----- Pre-requisites: 3 Buttons, and a TON of CheckBoxes. ----------\\
Public Class Form1
Private arCB() As String = Nothing '// string Array to store the CheckBoxes Names and CheckStates.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "save"
Button2.Text = "clear"
Button3.Text = "load"
End Sub
'// Save Names and CheckStates as Arrays to arCB.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sTemp As String = "" '// string to add Names and CheckStates to Split into Arrays.
For Each ctl As Control In Me.Controls '// loop thru all Controls.
If TypeOf (ctl) Is CheckBox Then '// check if Control Is CheckBox.
Dim cb As CheckBox = ctl '// declare CheckBox to get CheckState.
sTemp &= "~" & cb.Name & "#" & cb.CheckState '// add CheckBox.Name and "#" and CheckBox.CheckState
'//--- "#" is used to split Array again to extract CheckBox.Name and CheckBox.CheckState
End If
Next
arCB = sTemp.Split("~") '// add each CheckBox.Name and CheckBox.CheckState as a Array.
End Sub
'// clear CheckBoxes.CheckStates. -- TESTING PURPOSES ONLY.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For Each ctl As Control In Me.Controls
If TypeOf (ctl) Is CheckBox Then
Dim cb As CheckBox = ctl
cb.Checked = False
End If
Next
End Sub
'// Load CheckStates from arCB.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'//-- start with Index 1 since Index 0 is Empty. …
See if this helps for populating a ListView from a .csv file.
'// file located here: http://seepeoplesoftware.com/downloads/older-versions/11-sample-csv-file-of-us-presidents.html
Dim myCSVfile As String = "C:\USPresident Wikipedia URLs Thmbs HS.csv"
'// read File into Arrays.
Dim arFileLines() As String = IO.File.ReadAllLines(myCSVfile)
'// read line 1 to get Columns.
Dim arLineContent() As String = arFileLines(0).Split(",")
'// add Columns to ListView.
ListView1.View = View.Details
For Each lineArray As String In arLineContent
ListView1.Columns.Add(lineArray)
Next
'//------ populate ListView.
'// start with line 2 since line 1 is for Columns.
For i As Integer = 1 To arFileLines.Length - 2 '// -2 to remove the last president. :D
arLineContent = arFileLines(i).Split(",") '// split line into arrays.
'// create new item and subitems.
Dim newLvItem As New ListViewItem
With newLvItem
.Text = arLineContent(0) '// add Item.
For x As Integer = 1 To arLineContent.Length - 1
.SubItems.Add(arLineContent(x)) '// add SubItems.
Next
End With
ListView1.Items.Add(newLvItem) '// add to ListView.
Next
'------\\
See if this helps.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) = 46 Then '// if "dot".
e.Handled = True '// cancel out the key pressed.
TextBox1.SelectedText = "- test -" '// replace the selection.
End If
End Sub
Dim dt As Date = "12/13/2010"
MsgBox(Format(dt, "yyyy-MM-dd"))
Under those circumstances, declaring your "id" at a Class Level, seems appropriate.
I just thought I would offer a suggestion about using a Static Declaration within a Sub Procedure.
A Global Declaration should be used for what it is.
There is no reason to add your "id" with the rest of the Global Declarations if only used once.
I would also add my "id" in the "public sub pull_data" if that Sub Procedure ends up having to use the "id" to process code.
If your "public sub pull_data" is needed for other results, not just for when the "id" is needed, Declaring something like "Static id as integer = newid" within that Sub Procedure should keep account for the "id"'s value.
Public Sub pull_data(Optional ByVal newid As Integer = 0)
Static id As Integer = newid
' MsgBox(id)
'select whatever from whatever where id = id
End Sub
Unless you plan to reuse your "id" Integer from multiple Forms, method #2 is probably the best way to go about it.
Confusing to understand since both, the line with spaces and the line that should be read as, contain spaces.:D
See if this helps otherwise.
Dim sTemp As String = "12 25.53 35" '// your String.
sTemp = sTemp.Replace(" ", "") '// replace space with nothing.
MsgBox(sTemp) '// display result.
employeeform.dtbday.Text = Format(CDate(("Birthday").ToString), "MM/dd/yyyy")
Conversion from string "Birthday" to type 'Date' is not valid.
employeeform.dtbday.Text = Format(CDate((ListView2.SelectedItems.Item(0).SubItems(4).Text).ToString), "MM/dd/yyyy")
the items in the listview should be display in the textboxes in the other form whenever i click select data
See if this helps.
Private Sub ListView2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView2.Click
If Not ListView2.SelectedItems.Count = 0 Then '// check if item is selected.
With ListView2.SelectedItems.Item(0)
Form2.TextBox1.Text = .Text '// column 1.
Form2.TextBox2.Text = .SubItems(1).Text '// column 2.
Form2.TextBox3.Text = .SubItems(2).Text '// column 3.
Form2.TextBox4.Text = .SubItems(3).Text '// column 4.
'// etc...
End With
'Form2.ShowDialog()
End If
End Sub
Form2 has 4 TextBoxes for the first few Columns.
Adding more TextBoxes and using the "ListView2.SelectedItems.Item(0).SubItems(#).Text" will get your TextBoxes loaded with the SelectedItem's values.
You can always add images to your Application's Resources.
..File Menu / Project / "your application's name" Properties.
....Resources Tab, top Button for "Add Resource", click Drop-Down arrow, select "Add Existing File...", and load your images.
To access them, view the following code sample.
This code is from me adding 2 images to my Resources, "green.png" and "red.png".
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
Button1.BackgroundImage = My.Resources.green
End Sub
Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
Button1.BackgroundImage = My.Resources.red
End Sub
Adding images as a Resource will keep them stored within your Application.
Its up to you to decide on how strong a password is.
This will tell you how many uppercase, lowercase, numbers, and non numbers are in the password. You'll have to decide on what percentage of each is a strong password.
No one can decide for you what a "strong" password is.
You could add all the numbers up and depending on the total, set the color of your Label.
Not a very good approach, but a start.
Here is a code sample with a slightly modified version of Unhnd_Exception's code.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim t As String = TextBox1.Text
Dim iUpper, iLower, iNumbers, iOther As Integer
For i As Integer = 0 To t.Length - 1 '// Loop thru all Characters in TextBox1.Text
If Char.IsLetter(t(i)) Then
If Char.IsUpper(t(i)) Then : iUpper += 2 '// 2 Points for UpperCase.
Else : iLower += 1 '// 1 Point for LowerCase.
End If
ElseIf Char.IsNumber(t(i)) Then : iNumbers += 3 '// 3 Points for #'s.
Else : iOther += 5 '// 5 Points for Special Charaters.
End If
Next
Dim iSetTotal As Integer = iUpper + iLower + iNumbers + iOther '// sum Total.
If iSetTotal <= 5 Then Label1.BackColor = Color.Red '// if Less than 6.
If iSetTotal > 5 AndAlso iSetTotal <= 10 Then Label1.BackColor = Color.Orange '// if Greater than 5 and less that 11.
If iSetTotal > 10 Then Label1.BackColor = Color.Green '// if Greater …
I would use the _TextChanged Event.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim t As String = TextBox1.Text
'// Remaining code here.
End Sub
Here is something for Arguments.
In the application you want to load with Arguments, in Form_Load add similar code.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each myCoolArg As String In My.Application.CommandLineArgs
Select Case myCoolArg
Case "bgSteelBlue"
Me.BackColor = Color.SteelBlue
Case "bgSpringGreen"
Me.BackColor = Color.SpringGreen
End Select
Next
End Sub
The above code is for your .exe application.
Now, to load the above .exe application and change the Background Color, all you have to do is use this code.
Process.Start("C:\Users\codeorder\Desktop\vb.net\WindowsApplication1\WindowsApplication1\bin\Debug\WindowsApplication1.exe", "bgSteelBlue")
Of course, the path of your .exe's application should be edited for the above code to work.
Also, if you create a Shortcut for your .exe application that has Argument(s) options, right click the Shortcut, select Properties, and modify the "Target" textbox to contain a blank space and your argument.
C:\Users\codeorder\Desktop\vb.net\WindowsApplication1\WindowsApplication1\bin\Debug\WindowsApplication1.exe bgSpringGreen
Hope this helps.
See if this helps.
'//----------- Pre-requisites: 3 Buttons, 1 RichTextBox. ---------------\\
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "New"
Button2.Text = "Open"
Button3.Text = "Save" : Button3.BackColor = Color.LightGreen
RichTextBox1.Tag = "new" '// set .Tag to determine as New File.
End Sub
'// new file.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RichTextBox1.Clear() '// clear RichTextBox.
RichTextBox1.Tag = "new" '// set .Tag to determine as New File.
Button3.BackColor = Color.LightGreen
End Sub
'// open file.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ofd As New OpenFileDialog
ofd.Filter = "RTF Files (*.rtf)|*.rtf|TXT Files (*.txt)|*.txt|All Files (*.*)|*.*"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
If ofd.FileName.ToLower.EndsWith(".rtf") Then '// determine if a .RTF File.
RichTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.RichText)
Else
RichTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText)
End If
RichTextBox1.Tag = ofd.FileName '// set .Tag to FileName.
Button3.BackColor = Color.LightGreen
End If
End Sub
'// save file.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Not RichTextBox1.Tag = "new" Then '// check if .Tag is NOT a NEW File.
If RichTextBox1.Tag.ToString.ToLower.EndsWith(".rtf") Then '// determine if a .RTF File.
RichTextBox1.SaveFile(RichTextBox1.Tag.ToString, RichTextBoxStreamType.RichText)
Else
RichTextBox1.SaveFile(RichTextBox1.Tag.ToString, RichTextBoxStreamType.PlainText)
End If
Button3.BackColor = Color.LightGreen
MsgBox("File Saved.")
Exit Sub '// skip the SaveFileDialog.
End If
Dim sfd As New SaveFileDialog
sfd.Filter = "RTF Files (*.rtf)|*.rtf|TXT Files (*.txt)|*.txt|All Files (*.*)|*.*"
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
If sfd.FileName.ToLower.EndsWith(".rtf") Then '// determine if a .RTF File.
RichTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.RichText)
Else
RichTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText)
End If
RichTextBox1.Tag = sfd.FileName …
Let's take the "other" programmer's example and see what results we get.
Dim stringSomething As String = "some string"
stringSomething = "some other string"
MsgBox(stringSomething)
Total characters: 109
Now let's take "your" example.
Dim strSomething As String = "some string"
strSomething = "some other string"
MsgBox(strSomething)
Total characters: 100
... Now, 9 characters difference is not a big deal, but when constantly reused, "it is a big deal".
Here are a few reasons why.
1. The less code for an application to locate and process, the quicker the application. Correct?
2. The less time you waste typing extra "unnecessary" characters, the quicker you get results done. Correct?
3. The less time your application takes to respond to some code, the less "electricity" used. Correct?
4. The less electricity used, the more we have to offer to the future of our world, resources wise. Correct?
... This not only pertains to "electricity", but everything else, including hard-drive space, less usage of processor(s), among all that relates to a computer.
... If needed be said, the resources we use while typing "unnecessary" characters should also be taken in consideration. Food, water, etc.
5. The less time "the rest of the world" wastes to download/install your "extra characters", ... You do the math.
Overall, I can probably write an entire book on this thread topic alone.:D
But personally, I think that I have provided all the information needed within …
Dim myCoolTimeDate As String = Format(DateTime.Now, "hh:mm:ss tt MM/dd/yy")
MsgBox(myCoolTimeDate)