|
nextImage is static (i.e. Shared in VB) so it is set to 0 only on first call to Timer1_Tick. It retains its value between successive calls which is what I think the OP requires.
The problem with Me.I is it could be changed outside of the handler by some unrelated code. When the handler is called you have no idea what the value of Me.I is so it's wide open to index out of bounds exception.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
OK. Sorry I missed that.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Easily done - often guilty of it myself.
When I thought about the bounds it struck me that this is better.
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Private Shared nextImage As Integer = 0
PictureBox1.Image = MyImage(nextImage)
nextImage = (nextImage + 1) Mod MyImage.Length
End Sub
Then you don't have to do anything if more images are added or some removed.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
hello
thanks for your rep.
yes it's works fine
this is what i changed
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'PictureBox1.Image = (MyImage(I))
Static nextImage As Integer = 0
PictureBox1.Image = MyImage(nextImage)
nextImage = (nextImage + 1) Mod MyImage.Length
End Sub
it's working as i was trying to
thanks a lot sir
have a nice day
|
|
|
|
|
riced wrote: Then you don't have to do anything if more images are added or some removed.
Good point.
I really should practice VB.Net more, if I want to play over here.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi, I think this is the right place to post,
I've coded quite a bit in VB Net so far, not very advanced stuff though, and I'd like to learn more.
What I'd really like to do is create application that communicate over LAN, and to start of with something basic.
Like I click a button on one PC and in a texture on the other PC it says something like hello.
I've tried searhcing the internet, and I have no idea where to start. So I'm hoping someone here can help.
Evenutally I'd like to get a webpage that when you click a button on that it sends something (like 'hello') to a VB app.
Then get a VB app to talk to a Picaxe microcontroller, (I have already created an electronic dice using Picaxe and Basic(not VB))
I have created a website with the basics of html and php, and can do a little Javascript.
Then be able to send something(again like 'hello') from a webpage to a microcontroller (though VB or not).
I'm willing to learn, and this is something I'd really like to do, so please don't just discard this topic as another person just wanting code and not doing anything for it.
Thanks,
Jonathan
|
|
|
|
|
Unluckily, there is no easy and straight answer to what you ask. Inter-process commuications can be done in many different ways, all of which have their pros and cons, and all of which require study. Sending data from a "webpage" to an application can be even more complicated.
My best suggestion is you start having a Google at inter-process communications or tcp communications with VB.NET, and that might get you started for your first issue.
For the second issue, you need something more complicated, like SOAP or similar. If your website and the application reside on the same machine, then you might make it simpler by thinking about some kind of "local" inter-process communication between your server-side code (php or whatever) and the application.
I know I'm not of much help here, but it's really a wide subject we're talking about.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I believe the topic (technology) you are looking for would be considered a webservice. Do a search here in CodeProject and you should find something.
Maybe this article will help: (it is written in C#, but you should be able to get the idea)
How to make a simple WebService and consume it.[^]
|
|
|
|
|
Thanks I found it relatively easy actaully, though I understand the code, I'm having a bit of trouble.
I got a VB app to send text to another VB app on a different PC then got a website (On my local network) to send text to the VB app (using TCP/sockets or whatever).
This is the code I have atm in the VB app:
Sub Main()
' Must listen on correct port- must be same as port client wants to connect on.
Const portNumber As Integer = 8000
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
Console.WriteLine("Waiting for connection...")
Try
'Accept the pending client connection and return
'a TcpClient initialized for communication.
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Console.WriteLine("Connection accepted.")
' Get the stream
Dim networkStream As NetworkStream = tcpClient.GetStream()
' Read the stream into a byte array
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Return the data received from the client to the console.
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
TextBox1.Text = clientdata
'Any communication with the remote client using the TcpClient can go here.
'Close TcpListener and TcpClient.
tcpClient.Close()
tcpListener.Stop()
Console.WriteLine("exit")
Console.ReadLine()
Catch e As Exception
Console.WriteLine(e.ToString())
Console.ReadLine()
End Try
That is then called when form1 loads. The problem I have is unless I have me.show() before calling the above sub, the form will not show. And when I do have me.show() the form is frozen (though it doesnt have "Not Repsonding").
Also after I have sent some text I can't send any more without restarting the app.
Some help would be greatly appreciated, I have trawled google for several issues I had with PHP and IIS so please forgive for asking straight here and not bothering with google.
Jonathan
|
|
|
|
|
Still need help here, anyone?
Jonathan
|
|
|
|
|
When you press the send program freezes and you can't do any thing
how i can add button puss resume and stop
Project here
http://www.mediafire.com/download.php?wugizujoeuy
modified on Saturday, June 6, 2009 4:04 PM
|
|
|
|
|
There's no way anyone is going to read through all of that code. You post just the relevant parts to the problem. But, from what I did read, this is a total mess. Your creating your own thread, using a background worker, async methods with synchronous methods, Buttons without a meaningful name (Button1, Button2, ...) and so on. The only place I can start with this is to scrap it and start over. I have no idea what any of this code is trying to do, other than send emails.
Start small. Try creating an app that sends a single email using synchronous methods. Then write another one using asynch methods. If you're trying to send lots of emails, trying writing an app using a background worker than just increments a counter one a second. Start small, understand the technologies you're using, then you can start putting these smaller examples together.
|
|
|
|
|
when i click button, send , progrem freez and i can't click buton stop or puss
(programme continuos sending)
I want to work with Multi-Threading and this method smtp.send (mail)
download the project to understand
modified on Saturday, June 6, 2009 4:21 PM
|
|
|
|
|
You are an idiot. Dave downloaded the project, how else would he know what variable names you used ? So, your code sucks. I would guess that you need to start slower, learn some basics before reattempting this task
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Hello:
Any one know of a VB 2008 express example with source code that shows how to open a MS Access database and list all of the tables.
I'm a novice try to learn how to open view and manipulate the data in each table.
I do not wish to tie up your time with a lot of questions
Thank you
|
|
|
|
|
Why don't you start with trying to manipulate the data in a single, known table, before you get into the more advanced stuff of manipulating the system tables in a database.
|
|
|
|
|
Hi,
I'm having trouble trying to create a relation between two DataTable in my DataSet. Im getting an error saying "NullReferenceException was unhandled"
I have a DataSet call "myDataSet"
I have two tables call "ConsoleDT" and "GameDT"
The primary key in ConsoleDT is "ConsoleID" and GameDT also has a column called "ConsoleID"
Heres my code
Dim Fkey As New ForeignKeyConstraint("FKGameConsole", myDataSet.Tables("ConsoleDT").Columns("ConsoleID"), myDataSet.Tables("GameDT").Columns("ConsoleID"))
myDataSet.Tables("ConsoleDataTable").Constraints.Add(Fkey)
Thanks
|
|
|
|
|
Your code is assuming that you actually have a table called "ConsoleDT" in myDataSet. It's also assuming that that table has a column called "ConsoleID". It's also assuming that there is a table called "GameDT" and that it has a column called "ConsoleID". And so on, and so on... It would probably be a good idea to check if these things exist before you try and use them.
|
|
|
|
|
Hmm I'm not sure I get you sorry. These things do exist, and have been created before I try to create the Foreign Key.
|
|
|
|
|
It would help to diagnose your problem if, when the exception occurs, you move the cursor over each member in the offending line, until you find the one that is Nothing.
If you then post back here with those details, you're more likely to get useful help.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Sure, those things exist in the database, but are they objects in your code?? Or do those references return "Nothing", or null in the C, C++, C# worlds. When the code breaks and returns to the debugger, you can check to see if those objects actually return anything by hovering the mouse of them or looking in the Local Watch window.
|
|
|
|
|
Hi guys,I have a project to come up with a calculator to perform basic addition,subtraction,multiplication and division. I came up with the code below but it only adds correctly the first time...multiple addition always gives me a wrong answer and so does any attempted subtraction,multiplication and division....point out the errors please
CALCULATOR CODE:
Public Class Form1
Dim total1 As Single
Dim total2 As Single
Dim total3 As Single
Dim result As Single
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn5.Text)
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn1.Text)
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn2.Text)
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn3.Text)
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn4.Text)
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn6.Text)
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn7.Text)
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn8.Text)
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btn9.Text)
End Sub
Private Sub btnzero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnzero.Click
txtdisplay.Text = Val(txtdisplay.Text) & Val(btnzero.Text)
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
total1 = Val(txtdisplay.Text)
total1 = total1 + Val(txtdisplay.Text)
total2 = total1
result = total2
txtdisplay.Clear()
End Sub
Private Sub btneql_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneql.Click
txtdisplay.Text = result
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
txtdisplay.Clear()
total1 = 0
End Sub
Private Sub btntimes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntimes.Click
total1 = Val(txtdisplay.Text)
total1 = total1 * Val(txtdisplay.Text)
total2 = total1
result = total2
txtdisplay.Clear()
End Sub
Private Sub Buttbtndivideon15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttbtndivideon15.Click
total1 = Val(txtdisplay.Text)
total1 = total1 / Val(txtdisplay.Text)
total2 = total1
result = total2
txtdisplay.Clear()
End Sub
Private Sub btnless_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnless.Click
total1 = Val(txtdisplay.Text)
total1 = total1 - Val(txtdisplay.Text)
total2 = total1
result = total2
txtdisplay.Clear()
End Sub
End Class
|
|
|
|
|
keymoney wrote: point out the errors please
Other than the entire application?? Serisouly, IMHO, the entire thing needs to be scrapped and rewritten.
I'll give you a hint. You only need to keep track of two numbers. The first is an accumulator, the second is the current value in the display. All the math operations occur using just those two numbers.
|
|
|
|
|
keymoney wrote: ...it only adds correctly the first time...
Are you sure?
Trying to follow your logic, enter 15, press add, result now equals 30, display cleared. Enter 6, press equals, display shows 30, instead of 21, the actual sum. (Or at least I think it does - just reading it makes my head hurt...)
Your logic is, for want of a better word, insane.
total1 = Val(txtdisplay.Text)
total1 = total1 + Val(txtdisplay.Text)
total2 = total1
result = total2
What, exactly, do you think that code does? You need to step through in debug mode, looking at the values of the variables you're setting. Then, as Dave K. above suggests, throw it away and start again...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Hi,
I am doing a project related to School management. In that i was assigned by a module called Accounts Module. In this module i have to create Groups(like Assets,Liabilities,etc.,) and Accounts in the Treeview format.
I have one Textbox and two Comboboxes, in one combobox i have to select Group/Account, In the other combobox, i have to select 'under' which group the textbox value should be saved. We can add 'n' number of childs, sub childs Under the Groups, But when we select Value in the combobox as Account, we cannot add any values under the Account.
For better understanding, i will give a sample Treeview structure..
Assets (Group)
|-Current Assets (Group)
|-sample1 (Account)
|-sample2 (Account)
|-fixed assets (Group)
|-samp1 (Account)
liabilities (Group)
|-current liabilities (Group)
|-samp1 (Group)
|-samp2 (Acccount)
i think this is the best example..
Can anyone please help me in completing this Task..
Thanks in Advance,
Victoria
VB.Net
|
|
|
|
|