I managed to get all the items in my table by using your first posted code.
I just need an If statement here and there to only get the items with the selected year, although overall I'm getting results.
Thanks for all your help. :)
I managed to get all the items in my table by using your first posted code.
I just need an If statement here and there to only get the items with the selected year, although overall I'm getting results.
Thanks for all your help. :)
Hello everyone. I'm new to this forum and PHP in general.
I finally got the nerve to tackle a mySql Database on my website's server, added columns and a few values, although I cannot seem to find any online help to retrieve the values from the database table.
Here is my test html page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>mySql beta test</title>
</head>
<body>
<div id="content">Selected Year:</div>
<select id="years" onclick="javascript:getValues();" style="font-size:32px;">
<option>2011</option>
<option>2010</option>
<option>2009</option>
</select>
<script type="text/javascript">
function getValues() {
var i = document.getElementById('years').selectedIndex;
var selectedYear = document.getElementById('years').options[i].value;
var selDBitems = '';
// Need help here to connect to mySql, retrieve all items in table that have the selected year,
// and write the values to a string.
// selDBitems += ?????
document.getElementById('content').innerHTML = selDBitems;
}
</script>
</body>
</html>
Basically, I want to connect to mySql's table, which has 4 columns for: year,name,info,description, and retrieve values.
For this thread and to get my head a little more clear about using php, I only need to retrieve the database items that have the same year as the year selected in the <select> box.
Thanks kindly in advance.
How's this for a picture?
Forbidden
You don't have permission to access /software_screenshot/full/240697-Online_Rental_System.jpg on this server.
Also, see if this helps.
Dim sTemp As String = "a_b_c_d" '// your String.
Dim arTemp() As String = sTemp.Split("_"c) '// .Split String into Arrays.
For Each itm As String In arTemp '// loop thru Arrays.
'// find your Array and get value.
If itm.StartsWith("c") Then MsgBox(itm)
Next
See if this helps.
Protected Sub pullUpChildRecords_Click(ByVal sender As Object, ByVal e As EventArgs) Handles pullUpChildRecords.Click
If Not childIDText.Text = "" Then
MsgBox("Value cannot be empty in TextBox")
Else
'// run code here.
End If
End Sub
>>I keep getting the error "Object reference not set to an instance of an object" and can't figure out what is wrong.
On which line?
See if this helps.
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Not Module1.sUserKeptAsPermanent = Nothing Then
Form2.Label1.Text = sUserKeptAsPermanent
Else
sUserKeptAsPermanent = TextBox1.Text
Form2.Label1.Text = Module1.sUserKeptAsPermanent
End If
Form2.ShowDialog()
End Sub
End Class
Module Module1
Public sUserKeptAsPermanent As String = Nothing
Public user1 As String = Nothing
End Module
Basically, you set the String in the Module once and always load same String.
As for user1 String, not sure what it is needed for.
See if this helps.
Private ar1(3) As String
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
MsgBox("current Array.Length: " & ar1.Length)
ReDim Preserve ar1(ar1.Length + 4) '// increase by 5, since Arrays start at 0, not 1 and .Length starts at 1.
MsgBox("ReDim'ed and New Array.Length: " & ar1.Length)
End Sub
...for it will be for my advantage.
If a binary star is a system of two stars that revolve around each other, is Earth's Sun a singularity star?
Wonder
I need to learn db related stuff just not to look like a noob around some of you guys, although feeling like a noob is kind of nice since I am not feeling on top of the world all the time and brings me back to reality.
"codeorder": the code you pasted shows a mistake in VB 2005.
The word "with" is highlighted as a mistake and says that "End Of Statement [is] Expected"
If it is for line39, then the End With statement is there.
If using vb2005, try adding each line in the With statement on it's own line, not with the ":" char. to combine code lines as one.
If just needing something to do and improve and you programming environment, you can download the 2008 express or the 2010 express versions from Microsoft. 2005 "is so like yesterday":D.
See if this helps.
Dim arMovies() As String = {"Rise of the Planet of the Apes (2011)", "Mr. Popper's Penguins (2011)", "X-Men: First Class (2011)"} '// for testing.
For Each itm As String In arMovies
MsgBox(itm)
Next
'//------ OR...
For i As Integer = 0 To arMovies.Length - 1
MsgBox(arMovies(i))
Next
>>Is it possible to insert an item into a combobox that is data bound?
From what I know, not possible.
Otherwise, see if this helps.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim x() As String = {"1", "2", "3"} '// Array for testing.
ComboBox1.DataSource = x '// add as DataSource.
reloadCmb(ComboBox1)
End Sub
Private Sub reloadCmb(ByVal selComboBox As ComboBox)
With selComboBox
'// store all items from cmb.
Dim arlTemp As New ArrayList
For Each itm As String In selComboBox.Items : arlTemp.Add(itm) : Next
'// reload items after adding your item.
.DataSource = Nothing '// clear the connection from cmb, should clear the cmb.Items.
.Items.Add("Please select...") '// add your item.
For Each itm As String In arlTemp : selComboBox.Items.Add(itm) : Next '// add DataSource items.
.SelectedIndex = 0 '// select first item.
End With
End Sub
Seems that line 13 is causing the error since it probably is an Array and you need to have an index for which Array to get the value from, not the entire Array.
Try this:
MsgBox(movieArray(a))
See if this helps.
Public Class Form1
Private arLetterChars() As Char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 "
Private arEncryptedChars() As Char = "¿s¢çc‹i˜Ö´åÄÚKÍìæ¯~4Ûÿ5ÑûÏÉí³èô§ŠÀÙ9ÒÓ?þ.äƒ%*𾆱HI2@æŒ,"
'// encrypt.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
With TextBox1
For Each myTextBoxChar As Char In .Text '// loop thru TextBox, one char. at a time.
For i As Integer = 0 To arLetterChars.Length - 1 '// loop thru all letters in the Array.
'// if TextBox char ='s the char in your Array, replace the TextBox char with the same #'ed Array char of the Encrypted letters.
If myTextBoxChar = arLetterChars(i) Then .Text = .Text.Replace(myTextBoxChar, arEncryptedChars(i))
Next
Next
End With
End Sub
'// decrypt.
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
With TextBox1
For Each myTextBoxChar As Char In .Text '// loop thru TextBox, one char. at a time.
For i As Integer = 0 To arEncryptedChars.Length - 1 '// loop thru all Encrypted char.s in the Array.
'// if TextBox char ='s the char in your Array, replace the TextBox char with the same #'ed Array char of the Letters.
If myTextBoxChar = arEncryptedChars(i) Then .Text = .Text.Replace(myTextBoxChar, arLetterChars(i))
Next
Next
End With
End Sub
End Class
This uses 2 For/Next loops.
First loop, loops through each char. in the TextBox, one at a time. The loop inside the first loop, loops through the char.s in your Arrays, depending on which Array to use, if to encrypt or decrypt.
If a letter is the same letter as in …
unaiseek, for future references, start your own thread and do not spam other's threads with "your" question. Thanks and I hope this helps to get your issue taken care of.
Make what work?
You said "easy", correct?:D
'// encrypt.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
With TextBox1
.Text = .Text.Replace("a", "z").Replace("b", "y").Replace("c", "x")
End With
End Sub
'// decrypt.
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
With TextBox1
.Text = .Text.Replace("z", "a").Replace("y", "b").Replace("x", "c")
End With
End Sub
To not have a similar # added to another TextBox, I used the .Validated event, which when the selected TextBox looses focus, it fires.
To have this work, you need to add this line of code to each of your loops that creates a TextBox, possibly right before adding the TextBox to the Form.
AddHandler .Validated, AddressOf _TextBoxes_Validated
And the code that makes it all work, is this:
Private txtSelected As TextBox = Nothing '// declared once.
Private Sub _TextBoxes_Validated(sender As Object, e As System.EventArgs)
txtSelected = CType(sender, TextBox) '// get selected TextBox.
For Each ctl As Control In Me.Controls '// loop thru all Controls.
If TypeOf ctl Is TextBox AndAlso ctl.Name.StartsWith("textboxfrom_") Then '// find TextBoxes that have .Names starting with "textboxfrom_".
If Not txtSelected Is ctl AndAlso txtSelected.Text = ctl.Text Then'// if Not TextBox typed in is the TextBox in the loop and if .Text=.Text of loop Textbox.
txtSelected.Focus() : txtSelected.SelectAll() '// set focus and select all text if same # in another TextBox.
MsgBox("Similar # in another TextBox", MsgBoxStyle.Critical) '// prompt if needed.
End If
End If
Next
End Sub
Regarding:
>>...generate all the possible combination of the numbers a user types into the textboxes
Are you trying to add numbers as 1,2,3,4,5,etc. in the TextBoxes, and have the numbers added to the ListBox in Random order?
For example, you have 1,2,3,4,5 in 5 TextBoxes, and the ListBox should add items of "1,3,2,4,5","1,4,3,2,5","5,4,3,2,1", and so on?
If I'm on the right …
See if this helps.
1 Timer
Public Class Form1
Private myRunningProcesses() As Process
Private myAPPthatCrashes As String = "notepad", myKeyboardApp As String = "calc", bAppFound As Boolean
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With Timer1
.Interval = 1000 '// 1 sec.
.Start()
End With
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
myRunningProcesses = Process.GetProcesses '// get current Processes.
bAppFound = False
For Each selectedProcess As Process In myRunningProcesses '// loop thru all Processes.
If selectedProcess.ProcessName.ToLower = myAPPthatCrashes Then
bAppFound = True
Exit For '// exit loop since the app. is running.
End If
Next
If bAppFound = False Then '// check if app. not found.
For Each selectedProcess As Process In myRunningProcesses '// loop thru all Processes.
If selectedProcess.ProcessName.ToLower = myKeyboardApp Then
selectedProcess.Kill() '// terminate the keyboard app..
Exit For '// exit loop since located and terminated.
End If
Next
End If
End Sub
End Class
I used Notepad as your app. that crashes and Calculator as the keyboard app..
You could probably locate the "Posts:..." line and extract from there. Storing in a db, not a db coder here.
Pages containing xml, if a xml page and no html involved, then post some xml content and specify what you want to extract. Otherwise, post html & xml page content.
See if this helps.
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'// CInt="Convert To Integer".
If CInt(txtInput.Text) >= 0 AndAlso CInt(txtInput.Text) <= 9 Then '// if correct # entered, proceed.
Dim rnd As New Random '// declare new random.
lblRandom.Text = rnd.Next(0, 10).ToString '// Randomize (0 is minimum #, 10 is max and will only randomize to 9)
If CInt(txtInput.Text) > CInt(lblRandom.Text) Then lblOutput.Text = "You Win!"
If CInt(txtInput.Text) < CInt(lblRandom.Text) Then lblOutput.Text = "You Lose!"
If CInt(txtInput.Text) = CInt(lblRandom.Text) Then lblOutput.Text = "Draw!"
Else
MsgBox("Number entered can only be between 0 and 9.", MsgBoxStyle.Critical)
txtInput.Select()
txtInput.SelectAll()
End If
End Sub
'// Numeric TextBox.
Private Sub txtInput_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtInput.KeyPress
Select Case e.KeyChar
Case "1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "0"c, CChar(vbBack) '// allow numeric and backspace.
Exit Sub
Case Else
e.Handled = True '// block.
End Select
End Sub
End Class
Looks like you have not bothered to try and modify the code with the updates I posted in this post.
It should not be too much of a difficulty adding/editing code lines to code already there, even for a vb.noob.
Try updating the code yourself and if still w/out results, post the updated code.
That wall is my strength against beasts.
"Code's Soul" is the title of my autobiography book that I plan to have published someday.
Balance
... the wall in the fact kingdom.
To have style is to be unique.
Challenge
Use the If statements inside one another.
If 1 > 0 Then
If 2 < 3 Then
If 4 = 4 Then
MsgBox("You Win! :)", MsgBoxStyle.Information)
Else
MsgBox("error", MsgBoxStyle.Critical)
End If
Else
MsgBox("You Tie! :/", MsgBoxStyle.Information)
End If
Else
MsgBox("You Loose! :(", MsgBoxStyle.Information)
End If
With TextBox1.Text.ToLower '// use .ToLower to NOT make it Case SensITive.
If .Contains("something") Then MsgBox("Found.") Else MsgBox("Not Found.")
End With
Post your code, "sir"!
For love was nowhere in their sight.
(brutal little s.o.b.'es, those rabbit penguins :D)
For that sTemp
underline error, copy entire code from lines 43 to 49 in my originally posted code. It is showing as an error since you do not have sTemp
declared, as "Dim sTemp As String...".
The second one, just by looking at the image, I can say that you are probably missing the End if
for that If statement line. Try adding an End If
right above the Next
line in the Timer1_Tick event and let me know the results.
I have unfeigned respect for those that post in this thread, for it is better than a cup of coffee in the morning.
Option
That code works fine here, especially if I add a .Tag to each item in the ListView.
Try it in a new project and if it still errors, post the code here and let us know which lines are throwing what error.
Glad I could help. :)
You can also extract other stuff from the WebBrowser:
With WebBrowser1.Document.Body
TextBox1.Text = .OuterText
'TextBox1.Text = .InnerText
'TextBox1.Text = .InnerHtml
'TextBox1.Text = .OuterHtml
End With
I tested the .InnerHtml and it did not return the posts in it. Usually, .InnerHtml is the source code you need when extracting data.
Mine is also returning a "The remote server returned an error: (404) Not Found." error.
In such cases, a hidden WebBrowser could do the trick by extracting the .OutterText.
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Cursor = Cursors.WaitCursor
WebBrowser1.Navigate("http://www.vbforums.com/showthread.php?t=654378")
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
TextBox1.Text = WebBrowser1.Document.Body.OuterText
Me.Cursor = Cursors.Default
End Sub
End Class
Locating the "Originally Posted by..." line, you know that the following line(s) contain the post. The signature line of "______" could stop the content extraction, although in some cases there might not be a signature.
Hope this helps and good luck.
Seems that you are not storing/saving the updated text. Either save it or store it in a String.
2 TextBoxes (use TextBox1 to type in commands)
Public Class Form1
Private sUpdateOfTxt2 As String = "updating content" '// stores updated text of TextBox2.
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
With TextBox2
If .ReadOnly = False Then .ReadOnly = True '// set to True if False.
Select Case TextBox1.Text.ToLower
Case "add" : .Text = "adding content"
Case "delete" : .Text = "deleting content"
Case "update" : .ReadOnly = False : .Text = sUpdateOfTxt2
Case Else : .Text = "standby mode"
End Select
End With
End Sub
Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox2.TextChanged
With TextBox2
If .ReadOnly = False Then sUpdateOfTxt2 = .Text '// set text to String for storing.
End With
End Sub
End Class
Seems that your error is because you are not setting anything to item.Tag when adding new item to the ListView.
I have added a new If statement in the Timer1_Tick event, lines 18-20 of my previous posted code.
'///////////////////////////////
If Not itm.Tag Is Nothing Then
If itm.Tag.ToString = "start countdown" Then
'////////////////////
I also added the same If statement for lines 55-57.
With ListView1.SelectedItems(0)
'// toggle start/stop of countdown.
If Not .Tag Is Nothing Then If .Tag.ToString = "start countdown" Then .Tag = "stop countdown" Else .Tag = "start countdown"
End With
This should stop the errors, although your Timer will not subtract time from the items since you need to have the .Tag set to "start countdown".
All you have to do when adding a new item to your ListView, set the .Tag property of it to "start countdown".
Dim lvItem As New ListViewItem(sTemp.Split(CChar(",")))
'////////////////////////
lvItem.Tag = "stop countdown" '// set to "stop ..." to not automatically start the countdown.
'//////////////////////
ListView1.Items.Add(lvItem)
Saving to db(database), not a db coder here. Good luck with that.
As for start/stop time of individual users, I ended up using the .Tag Property of each ListViewItem added. The .Tag property is a hidden property which can be used for such cases as this. Each time you add an item to the ListView, you set the .Tag to something. If it's the correct .Tag, then the Timer will subtract time from that item.
See if this helps.
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ListView1 '// setup ListView.
.Columns.Add("Column 1", 100) : .Columns.Add("Column 2", 100) : .Columns.Add("Column 3", 100) : .Columns.Add("Column 4", 100) : .Columns.Add("Column Time", 100) : .View = View.Details : .FullRowSelect = True
End With
With Timer1
.Interval = 1000
.Start()
End With
Button1.Text = "Add User" : Button2.Text = "Start/Stop"
End Sub
Private arTimer() As String = Nothing '// Array to .Split time into hours/seconds.
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
For Each itm As ListViewItem In ListView1.Items '// loop thru all items in ListView.
'///////////////////////////////
If itm.Tag.ToString = "start countdown" Then
'////////////////////
With itm.SubItems(4) '// Get column 5.
If .Text.Contains(":") Then '// if it .Contains the ":".
arTimer = .Text.Split(":"c) '// .Split it into 2 Arrays.
If arTimer(1) = "00" Then '// check Array 2 for "00".
If CInt(arTimer(0)) > 0 Then '// if minutes are at "00" and Array 1 is greater than 0, the hours,
arTimer(1) = "59" …
See if this helps.
(1 Timer)
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With Timer1
.Interval = 1000 '// set interval to 1,000, which is 1 second.
.Start() '// start the Timer.
End With
End Sub
Private arTimer() As String = Nothing
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
For Each itm As ListViewItem In ListView1.Items '// loop thru all items in ListView.
With itm.SubItems(4) '// Get column 5.
If .Text.Contains(":") Then '// if it .Contains the ":".
arTimer = .Text.Split(":"c) '// .Split it into 2 Arrays.
If arTimer(1) = "00" Then '// check Array 2 for "00".
If CInt(arTimer(0)) > 0 Then '// if minutes are at "00" and Array 1 is greater than 0, the hours,
arTimer(1) = "59" '// set seconds to 59, and
arTimer(0) = CStr(CInt(arTimer(0)) - 1) '// subtract hour.
End If
End If
If Not .Text = "0:00" Then '// check if not at "0:00".
arTimer(1) = CStr(CInt(arTimer(1)) - 1) '// subtract 1 second from seconds.
If arTimer(1).Length = 1 Then arTimer(1) = "0" & arTimer(1) '// add a "0" if seconds are from 0-9.
.Text = arTimer(0) & ":" & arTimer(1) '// set .Text back to ListViewItem.
End If
End If
End With
Next
End Sub
End Class
Panels are in the Toolbox.
I would use a TabControl since it is easier to work with in .Designer and if needed, hide the tabs.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'// Hide Tab Headers in TabControl.
With TabControl1.TabPages(0)
TabControl1.Region = New Region(New Rectangle(.Left, .Top, .Width, .Height))
End With
End Sub
To select a TabPage afterward, check out this thread.
Since you cannot receive private messages, I'll post here and remind you to not forget to mark the thread solved if Solved. And of course, glad I could help. :)
I located this online:
http://www.softperfect.com/products/bandwidth/mainwindow.gif
(full app. info here)
Seems that the design for that imaged app., is a Menu, a ToolBar, and a ListView with columns.
Also a StatusBar.
Hope this helps with the interface design.
This might help also. Just change the ListBox to a ComboBox.
Dim myCoolFolder As String = "C:\!vbTemp\" '// your folder.
For Each myCoolFile As String In My.Computer.FileSystem.GetFiles _
(myCoolFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.*")
ListBox1.Items.Add(IO.Path.GetFileName(myCoolFile)) '// add file name with extension.
Next
'// to search subfolders, change "SearchTopLevelOnly" to "SearchAllSubDirectories".
'// to only get a certain file type, change "*.*" to your file type.
'//-- example for .txt files: "*.txt"
I'm a Brawny user. Tough, durable, and pick your own size, my favorite. :D
For a computer cleaner, check out this link.
http://www.vbforums.com/showpost.php?p=3393703&postcount=11
.I only tested the cache and cookies and it worked well.
If you need to view those folders, use this:
Dim myIEcacheFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
Process.Start(myIEcacheFolder)
Dim myIEcookiesFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.Cookies)
Process.Start(myIEcookiesFolder)
EDIT::
Forgot to mention.
I once tried to make a p.c. cleaner and I use Firefox for a default wb(WebBrowser).
I tried deleting all files in the Firefox cache folder, so I thought it was, and crashed my Firefox.
If working with Firefox, be careful not to crash it by deleting needed system files since they seem to be in the same folder as the cache, I believe. Good luck.
Destroying everything within their glaring path.
Hey, Nice job down voting this for someone who was just trying to get some other ideas and perspective.
How about next time you leave your name instead of dancing around like a twinkled toed douche bag.
Unhnd
Took care of it and gave you another fresh start as you did for yourself.
Company name from an IT forum member, here we go:
Evolved Construction
With a software developer's mind, Evolved should not be a difficult task.