|
OK. You can't take the approach you're using to fill in the username and password. You have to write code that gets this page, then finds the username and passwords HTML input boxes in the form, fill them in, then "click" on the Login! button to submit the filled in page back to the webserver.
|
|
|
|
|
Thanks for putting me in a right direction but can you please give me a hint which class i should use to fill the input boxes and to invoke the click event of Login button.
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
Sorry, but you use a Web Browser control to do this.
|
|
|
|
|
Thank you very much I'll try to figure it out.
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
I am trying to make a epos for a bar as a uni project have spoke to my tutor but he’s of no help and tells me to look it up on the net so here i am
Situation
On the First Sales screen i have 24 buttons (speedbar) the names will come from a db but if there are not 24 items in the database it stops due to it being out of range
This is my current code
<br />
<br />
Dim speedbar As New Collection<br />
Dim sql As String<br />
Dim ds As DataSet = New DataSet<br />
Dim cmd As OleDb.OleDbCommand = OleDbConnection1.CreateCommand<br />
cmd.CommandType = CommandType.Text<br />
sql = "select * from Drinks"<br />
cmd.CommandText = sql<br />
<br />
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter<br />
da.SelectCommand = cmd<br />
da.Fill(ds, "Drinks")<br />
<br />
Dim dc As DataColumn, dr As DataRow<br />
<br />
<br />
<br />
For Each dr In ds.Tables("Drinks").Rows<br />
speedbar.Add(dr.Item("Name"))<br />
Next<br />
As you can see a items for the speed bar are stored in a collection what i cant do (where i need your help please) is make the buttons dynamical or add the name to some and make the rest invisible
Thanks
aj
|
|
|
|
|
You create button the same way you create an instance of any other class, with New. You then set a bunch of properties on the button for size, location, Text, whatever, ... Then you add the button to the container form's Controls collection.
Dim newButton As New Button
newButton.Location = New Point(x, y)
newButton.Size = New Size(50, 75)
newButton.Text = someText
Me.Controls.Add(newButton)
Next, you have to wire up the button's Click event so you can get notified when the user clicks on it. That you do with the AddHandler statement:
AddHandler newButton.Click, AddressOf myButtonClickHandler
Of course, myButtonClickHandler has to have the signature of the appropriate event handler:
Private Sub myButtonClickHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
... code to handle the button click goes here
End Sub
Multiple buttons can be wired up to the same event handler.
|
|
|
|
|
how do i get it to make the right amount of buttons and name them all and put them in the right place
modified on Friday, May 9, 2008 2:16 PM
|
|
|
|
|
jacko873 wrote: how do i get it to make the right amount of buttons
Iterate over the returned rows in your datatable. One button for each row.
jacko873 wrote: put them in the right place
Simple math. All you have to do is calculate an offset from a fixed point multiplied by the count of buttons you've put down already.
|
|
|
|
|
Thank you Got the buttons working the names are right and the positions are great but I do have one last think to ask
How do I create an event for each button?
What I want the buttons to do is when they are clicked and an item to a list box and add the price to a variable for later
|
|
|
|
|
I already told you how to wire up the button's Click event.
|
|
|
|
|
I get that I can create event but each button has the same event
I what each event to be different dependant on the text of the button
|
|
|
|
|
Like was said before:
AddHandler newButton.Click, AddressOf myButtonClickHandler
but change myButtonClickHandler to the name of the method you want to be called onClick.
Edit:
pseudo code:
if button.text == string1 then
AddHandler newButton.Click, AddressOf myButtonClickHandler1
else if button.text == string2 then
AddHandler newButton.Click, AddressOf myButtonClickHandler2
etc etc
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Then you have to cast the Sender object back to a button. You can then use it just like it was dropped on the form in the designer:
Dim b As Button = DirectCast(sender, Button)
|
|
|
|
|
Hi,
I need some help with a VBA script in Excel 2003, its probably really simple but the macro recorder hasnt been much use and im not sure how to start.
All I want to do is:
Check a worksheet value (i.e. in call A1), for the first value check on another worksheet list
>> If this value is in a row, delete this row and all rows containing this value, if not, do nothing and check the next record
Then move onto the next record (i.e. in cell C2) until there are no records left to check
How would I do this please (or can you give me advise on how to do something similar so I can make a start at finding a solution?).
Many thanks in advance
|
|
|
|
|
I won't write code for exactly what you need but I have got similar example.
Sub CheckList()
Sheet1.Cells(1, 1) = "Text1"
Sheet2.Cells(1, 1) = "Text1"
Dim sValueFromSheet1 As String
Dim sValueFromSheet2 As String
sValueFromSheet1 = Sheet1.Cells(1, 1)
sValueFromSheet2 = Sheet2.Cells(1, 1)
If sValueFromSheet1 = sValueFromSheet2 Then
Sheet1.Activate
Rows("1:1").Select
Selection.Delete Shift
Range("A1").Select
End If
End Sub
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Is there a way to read a datatable from an .xml file on disk such that the created datatable contains only a subset of the records in the .xml table? Something simlar to the select statement in SQL? Certainly seems like there should be, but I can't seem to find it.
Thanks
|
|
|
|
|
cstrader232 wrote: Is there a way to read a datatable from an .xml file on disk such that the created datatable contains only a subset of the records in the .xml table? Something simlar to the select statement in SQL? Certainly seems like there should be, but I can't seem to find it.
You can't find it because it doesn't exist. The DataTable/DataSet objects load the entire XML file. You don't have the option of selecting just the records you want. You'd have to write you own implementation of this, probably based on using an XmlReader, and build the datatable yourself. Implementing a query language would be the hardest part of doing this.
|
|
|
|
|
Thank you... I guess I should save these tables in a database.
Would you be willing to look at my question on reflection that i posted on May 7th?
|
|
|
|
|
cstrader232 wrote: Would you be willing to look at my question on reflection that i posted on May 7th?
I already am, in what little free time I have.
|
|
|
|
|
Hi,
I know this may not be the place to post this, but it is about syntax in VB, so I thought it would be the best place.
(P.s. This is a VERY simplified example of what I want to do... I wouldnt waste effort with linq on something this simple )
I have a list of structures in VB, and can easily select an item from the list:
Public Structure UserInfo
Public ID As Integer
Public Name As String
End Structure
Dim Users As New List(Of UserInfo)
Users.Add(New UserInfo With {.ID = 1, .Name="Jim"})
Users.Add(New UserInfo With {.ID = 2, .Name="Bob"})
Users.Add(New UserInfo With {.ID = 3, .Name="Sue"})
Now, what I want to do is update user ID 3 (for example) to change the name from Sue to Susan...
At the moment I use this:
Dim User As UserInfo = (From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First
Users.Remove(User)
User.Name = "Susan"
Users.Add(User)
This works, but surely there is a better way? I have tried rooting through Google, but I am not sure of what I should be looking for to filter out all the Linq to sql and c# examples
Please help!
|
|
|
|
|
A structure should generally be immutable, and the point of using a structure is mostly defated as you have a reference type inside it. Use a class instead of a structure.
Public Class UserInfo
Public ID As Integer
Public Name As String
End Structure
Dim Users As New List(Of UserInfo)
Users.Add(New UserInfo With {.ID = 1, .Name="Jim"})
Users.Add(New UserInfo With {.ID = 2, .Name="Bob"})
Users.Add(New UserInfo With {.ID = 3, .Name="Sue"})
Now you don't have to remove and add the item to update it:
(From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for the reply - some very useful information in there. I do have one small problem though - I cant find the correct syntax for the update:
(From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
It doesnt work on its own in VB 2k8, and after hours of net searching, I cant find the answer . Using:
dim b as boolean = (From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
compiles, but obviously doesnt update anything (the expression above supposedly returns a boolean)
If you get chance, and you know the answer, can you post a quick message telling me...
Ta muchly!
|
|
|
|
|
I thought that the LINQ expression could be used as an expression, but obviusly it can't. If you put the result in a variable, it works:
Dim user As UserInfo = (From u In Users Where u.ID = 3 Select u).First
user.Name = "Susan"
Another way to do this (and more effective as it only looks until it finds the first occurance) is to use a lambda expression:
Users.Find(Function(u) u.ID = 3).Name = "Susan"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for that - you have been a huge help!
I cant believe I didnt try option 1 first though I think I tried everything but!
|
|
|
|
|
hi
in may project i exploit my data to exl sheet but the styel not very will because the size of the sill is smailer than data size
is their is way to make the sill size larger in my code not from the excel?
|
|
|
|