|
I've been looking at my (very simple) code for the better part of 2 hours now and just can't seem to find my mistake.
I want to draw an arrow (pointing down) on a label.
so I used the fillpath methode but it doesn't work, the strange thing is that when I use the drawpath methode it does work.
here is my code:
Private Sub drawarrow(ByVal g As Graphics)<br />
If Me.Height > 30 Then<br />
Dim widtharrow As Integer = 4<br />
Dim heightarrow As Integer = 4<br />
Dim heightmargin As Integer = 3<br />
Dim x1 As Integer = (Me.Width / 2) - (widtharrow / 2)<br />
Dim y1 As Integer = Me.Height - (heightarrow + heightmargin)<br />
Dim x2 As Integer = (Me.Width / 2) + (widtharrow / 2)<br />
Dim y2 As Integer = Me.Height - (heightarrow + heightmargin)<br />
Dim gp As New GraphicsPath<br />
gp.AddLine(x1, y1, x2, y2)<br />
x1 = (Me.Width / 2) - (widtharrow / 2)<br />
y1 = Me.Height - (heightarrow + heightmargin)<br />
x2 = Me.Width / 2<br />
y2 = Me.Height - heightmargin<br />
gp.AddLine(x1, y1, x2, y2)<br />
x1 = (Me.Width / 2) + (widtharrow / 2)<br />
y1 = Me.Height - (heightarrow + heightmargin)<br />
x2 = Me.Width / 2<br />
y2 = Me.Height - heightmargin<br />
gp.AddLine(x1, y1, x2, y2)<br />
gp.CloseFigure()<br />
'gp.CloseAllFigures()<br />
'gp.FillMode = FillMode.Alternate<br />
<br />
g.FillPath(Brushes.Blue, gp)<br />
'g.DrawPath(Pens.Black, gp)<br />
gp.Dispose()<br />
End If<br />
End Sub
if anyone spots what my mistake is please let me know
thanks
|
|
|
|
|
Hi,
you want a filled triangle, right ?
I am afraid FillPath is not smart enough to correctly fill a path specified in
random order, as you did.
I would use fewer formula, set three points (x1,y1), (x2,y2) and (x3,y3)
then do AddLine(1,2), AddLine(2,3), AddLine(3,1) so the path steps through the points
1,2,3 in the right order and closes back on itself. This will give no difference to DrawPath
but it will allow FillPath to understand and fill your polygon.
BTW: in fact you dont need the third line, FillPath closes the shape all by itself
if first and last point are not the same.
Hope this helps.
|
|
|
|
|
works perfectly now
thanks
and with way less code then I did it (I think I'll take a break now )
|
|
|
|
|
you're welcome.
yes, one of my rules is: when it is wrong, trim it rather than grow it ...
Greetings from Antwerp.
|
|
|
|
|
I'm making a log file and want to have a string of apostrophes to separate parts of the log file.
Dim divider As String
Dim t As TextStream
'other declarations are there like FileSystemObject but its irrelevant. The log works besides this string I desire'
divider = "''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''"
t.WriteLine(divider)
Now I've tried using the escape character \', using hyphens (-) and asterisks(*). Any ideas?
|
|
|
|
|
Hi, string class has a constructor specially for you: new String(char, repeatCount)
|
|
|
|
|
Just curious if there is some simple code, which can be modified and implemented to click a button in an app.
|
|
|
|
|
No. Controlling an application through it's user interface is complicated and problematic at best.
|
|
|
|
|
This requires getting the handle of the other app's windows including the button that you want to click. You can then send it a message that tells the button it has been clicked. It's all Win32 API work, not terribly hard, but you can cause problems if you don't follow the rules, and you may never know all of the rules. I don't have the code any more, or I don't know where it is, but I adapted it from Bill McKinney's excellent book: Hardcore Visual Basic, Second Edition, Copyright 1997, Microsoft Press. Unfortunately it is no longer in print.
If this is important enough, and there is no other way, then I recommend you find a used copy of it. Another excellent resource is: Visual Basic Programmer's Guide to the Win32 API bu Dan Appleman. This is still in print and I consider it to be the bible of Win API programming.
Test, test, and test again.
Tom Garth
Developer
R. L. Nelson and Associates, Inc., Virginia
|
|
|
|
|
Thank you very much. I will look into these books.
If any one has general code using Win32 API involving a simple
button click, this will save me time.
Until then, I am off to the library!
|
|
|
|
|
I want to update a quantity field in SQL Server from VB. First I have to check the value of the quantity field and then subtract a given amount from it. I thought I have to do a SQL select first to get the value and then do an SQL update. After the Sql select I need to lock the record until the Sql update is done. How can I lock the record? Or can I somehow update the record with the new quantity without using an Sql select?
|
|
|
|
|
update table set column = column - substraction
|
|
|
|
|
Locking a record is just about never a good idea, and in your case, you don't need to do this. If you have to update a column, all you have to do is execute a single SQL statement. Say you want to reduce a value by 5:
UPDATE tableName
SET columnName = columnName - 5
WHERE someRecordId = someIdValue
|
|
|
|
|
hi
am working on a project of a school that has many hostels. looking out for someone that will give me a code that will automatically select a hostel from a list of hostels and give it to the client filling the form. am using VB 6.0 fr this particular project
thanks
Daser solomon
Nigeria
Helping someone is simply helping oneself
|
|
|
|
|
What exactly do you want here is what I understand:
You're client logs in (or something) then you want a hostel that is pecificly for that client to be displayed.
If this is the case you'll have to keep track of wich hostel is 'linked' to wich client (you can do this in you're db if you use one)
then it is only a mater of selecting the right hostel from the list (wich I presume is gathered from a db) and this can be done in de sql string with an ID or something like it.
if ofcourse it doesn't matter wich hostel you give to the client (random one) look at the function random and give you're hostels an numeric id that way you can easly select one.
|
|
|
|
|
a tanks
i agree with this:
if ofcourse it doesn't matter wich hostel you give to the client (random one) look at the function random and give you're hostels an numeric id that way you can easly select one.
i have a thought question from your answer. is it that you are going to put those hostel in an array? if it is write then can u plz help me with a little code that will take care of that case
helping someone is automatically helping self
|
|
|
|
|
here a (very) simpel example of how you can do this
Public Class Form1<br />
Dim l As New List(Of hostels)<br />
Private Sub RibbonDropDownButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonDropDownButton1.Click<br />
Dim i As Integer<br />
Dim r As New Random<br />
i = r.Next(0, 10)<br />
For Each h As hostels In l<br />
If h.id = i Then<br />
MessageBox.Show(h.name)<br />
End If<br />
Next<br />
End Sub<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Dim i As Integer<br />
For i = 0 To 10 'just to fill the list with some values<br />
l.Add(New hostels(i, "test" & i))<br />
i += 1<br />
Next<br />
End Sub<br />
End Class<br />
<br />
<br />
Public Class hostels<br />
Dim iid As Integer<br />
Dim sname As String<br />
Public Property id() As Integer<br />
Get<br />
Return iid<br />
End Get<br />
Set(ByVal value As Integer)<br />
iid = value<br />
End Set<br />
End Property<br />
Public Property name() As String<br />
Get<br />
Return sname<br />
End Get<br />
Set(ByVal value As String)<br />
sname = value<br />
End Set<br />
End Property<br />
Public Sub New(ByVal iid As Integer, ByVal sname As String)<br />
Me.id = iid<br />
Me.name = sname<br />
End Sub<br />
End Class
as I said: very simpel one
if you work with a db you'l have to fill the list with what you extract from you're db
depending on wich version you use of vb you might have to use an 2 dimansial array instead of a list
hope this helps you on you'r way
|
|
|
|
|
tanks dude
i will have to test it. i will give you credit as soon as am done
helping someone is simply helping self
|
|
|
|
|
hello all
how to call php web services in vb.net,if any web server configuration required for that,please help.
|
|
|
|
|
If the web service you're talking about follows standards, all you need to do is add a web reference to it. Double-click MyProject in the Solution Explorer, click on the References tab, then click on the little downward facing triangle on the Add button and pick "Web Reference..." Type in the URL for the web service and click Go. If the web service comes back good, you can click Add Reference. Then you can create an instance of the web service just like you do any other object.
Dim myService As New WebServiceName
|
|
|
|
|
i have done all this thinks but my problem is when i want to access the function of this PHP web service it through transport connection problem , is any configuration required for apache server to access
|
|
|
|
|
one more thing is that whenever i check this web service with soap UI it return HTML Fragment instead of XML Fragment,please help
hope u understand my prob
thanks
|
|
|
|
|
Well, you're kind of out of luck as far as I know. I've never seen a web serive return HTML instead of XML.
|
|
|
|
|
Hi,
I have a form which is MdiContainer.
But I want to write in a database all the controls from this form and I see all the controls but if a control is System.Windows.Forms.MdiClient I can't see the name of this control.
please help.
thanks.
|
|
|
|
|
I don't know why but this seems to be correct
possible work around: give the name of the form in in the tag property and then access the tag property to know the name of the form
|
|
|
|