Pages: [1] :: one page |
Author |
Thread Statistics | Show CCP posts - 0 post(s) |

Krathos Morpheus
Legion Infernal
|
Posted - 2010.03.21 18:29:00 -
[1]
Hello! I'm making an application using EveAI, VS2010 and Visual Basic and since I'm new to programming I lack some basic knowledge, the code is becoming more and more complex and I'd like to put it in parts to organize it better, cleaning the main form and making it more legible.
I think I have to put the code in another vb file and there put it in subs made into a new class, my question is how do I call those subs from the main frame code? What previous steps are needed to make the subs available from another piece of code? Is it enough to make the subs as public? Is there another more efficient way to deal with this?
Thanks.
EVEwatch Sidebar soon "It is the unofficial force ù the Jita irregulars. " |

Xeross155
Minmatar Fusion Death Inc. Intrepid Crossing
|
Posted - 2010.03.21 22:23:00 -
[2]
Making them public should make them globally accessible --------------------------------------------- Xeross' ventures into EVE |

Krathos Morpheus
Legion Infernal
|
Posted - 2010.03.21 23:04:00 -
[3]
Originally by: Xeross155 Making them public should make them globally accessible
Don't I need to make a variable or import the class or something to make it load on the other file?
EVEwatch Sidebar soon "It is the unofficial force ù the Jita irregulars. " |

Krathos Morpheus
Legion Infernal
|
Posted - 2010.03.21 23:14:00 -
[4]
Ok, I think I've figured why it didn't work, I have to put the subrutines inside a module, not a class. I'll try it now.
EVEwatch Sidebar soon "It is the unofficial force ù the Jita irregulars. " |

Krathos Morpheus
Legion Infernal
|
Posted - 2010.03.21 23:43:00 -
[5]
I get an error that says I can not auto-reference the form and should use Me instead, but Me is not allowed inside a module, what am I doing wrong?
EVEwatch Sidebar soon "It is the unofficial force ù the Jita irregulars. " |

Cadde
Gallente 221st Century Warfare
|
Posted - 2010.03.22 00:26:00 -
[6]
Originally by: Krathos Morpheus I get an error that says I can not auto-reference the form and should use Me instead, but Me is not allowed inside a module, what am I doing wrong?
Use: Form1.TextBox1.Text
Instead of TextBox1.Text
That is just an example going off the top of my head based on the details you provided.
If anything, chat me up in game and i can give you live help.
My opinions belong to me, you can't have them!
|

Krathos Morpheus
Legion Infernal
|
Posted - 2010.03.22 00:45:00 -
[7]
Edited by: Krathos Morpheus on 22/03/2010 00:49:45 The following simplification breaks it, on frmMercader.vb I have this inside the public class of the form:
Quote:
Private Sub listAPIkeys_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listAPIkeys.VisibleChanged
If Me.listAPIkeys.Visible = True Then Call updateListApiKeys() 'updates api list when listApikeys is made visible End If End Sub
And inside UpdateLists.vb I have:
Quote:
Module UpdateLists
Public Sub updateListApiKeys() 'updates the list of APIs found on settings frmMercader.listAPIkeys.Items.Clear() End Sub
End Module
As you see I've already done what you suggested. If I put the updatelistapikeys sub on the frmMercader and change frmMercader for Me it works fine. Only thing I can imagine is that maybe the sub is called when loading the form and it breaks because of that.
EVEwatch Sidebar soon "It is the unofficial force ù the Jita irregulars. " |

Cadde
Gallente 221st Century Warfare
|
Posted - 2010.03.22 00:56:00 -
[8]
I had no problems running this code:
Form1.vb
Public Class Form1
Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Add("Test") ListBox1.Items.Add("Test2") ListBox1.Items.Add("Test3") ListBox1.Items.Add("Test4") ListBox1.Items.Add("Test5") ListBox1.Items.Add("Test6") application.DoEvents Threading.Thread.Sleep(2000) Call updateListApiKeys() End Sub End Class
Module1.vb
Module Module1
Public Sub updateListApiKeys() Form1.ListBox1.Items.Clear End Sub
End Module
However, your situation might be different. Hope this can help you determine whats wrong, otherwise chat me up in game.
My opinions belong to me, you can't have them!
|

Cadde
Gallente 221st Century Warfare
|
Posted - 2010.03.22 00:59:00 -
[9]
Originally by: Krathos Morpheus
As you see I've already done what you suggested. If I put the updatelistapikeys sub on the frmMercader and change frmMercader for Me it works fine. Only thing I can imagine is that maybe the sub is called when loading the form and it breaks because of that.
Try and put this at the beginning of form load.
Me.Show Me.Visible = True Application.DoEvents
And see if it resolves the problem. If it does then you know what happened, as the form wasn't already initialized. Also, try and refrain from running code on the form until it's properly initialized.
My opinions belong to me, you can't have them!
|

Krathos Morpheus
Legion Infernal
|
Posted - 2010.03.22 01:14:00 -
[10]
Edited by: Krathos Morpheus on 22/03/2010 01:14:19
looks like your not online now...
I think the difference could be in that you're triggering the sub with a click, but I do it when visibility changes wich happens while the software is loading. Maybe the error is there.
Update: Looks like it was that, avoiding the tab wich contains the control being focused or visible when loading should do the trick. Thanks for your help.
EVEwatch Sidebar soon "It is the unofficial force ù the Jita irregulars. " |

Cadde
Gallente 221st Century Warfare
|
Posted - 2010.03.22 01:17:00 -
[11]
Edited by: Cadde on 22/03/2010 01:20:15 Edited by: Cadde on 22/03/2010 01:19:04
Originally by: Krathos Morpheus Edited by: Krathos Morpheus on 22/03/2010 01:14:19
looks like your not online now...
I think the difference could be in that you're triggering the sub with a click, but I do it when visibility changes wich happens while the software is loading. Maybe the error is there.
Update: Looks like it was that, avoiding the tab wich contains the control being focused or visible when loading should do the trick. Thanks for your help.
I am online, i just happened to watch a movie while eating and didn't see the convo request.
EDIT: And btw, glad it works ;)
EDIT 2: And of course i lose connection to eve just now.
My opinions belong to me, you can't have them!
|
|
|
Pages: [1] :: one page |
First page | Previous page | Next page | Last page |