|
Hi. I would be considered beginner at VB so I hope this question is not bad.
I am working on a genetic algorithm for TSP problem. I will try describe what I am trying to do. I am try to create 10 x 10 matrix has zeros across in cells diagnal from upper left to lower right. For example: in TSP problem distance from point A to A, B to B, C to C, etc will have be zero. I am create random integers from 1 to 100 for other distance. So upper right and lower left must be also symetric. I can create matrix so each cell is random but can not do previous stated problem.
I hope this makes sense.
Any help is many appreciated.
|
|
|
|
|
Have you made any progress in this?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Yes, it was just a matter of entering:
_Array(y, x) = _Array(x, y)
_Array(x, y) = 0
_Array(x, y) = _Array(y, x)
in the middle of my nested for/next loop.
Thank you for the interest though.
|
|
|
|
|
Are you going to do an article here about your TSP project?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi, I have develop any application in vb2005. My application connect to ms. access database. i used textbox to display information and editing in my application. My problem challenge when i try to format the number in currentcy and return the value back to the database when user need to update the value.
In my database there is one field has datatype as currentcy. When its display in the textbox i use the code format(value, "$ #,###.##") to display the value. For example, 6000 display $ 6,000.00 . The problem is when i try to save the value back to the database, the value $ 6,000.00 will cause the problem because $ , and . character is not a valid character.
So, how could i code my application to take only 6000 value from the textbox which contain $ 6,000.00 value? Do i need to use any custom control?
Thank in advance!
|
|
|
|
|
You can change the control to not accept those keys, but if you like the way it displays, just string the string before you insert it, as in
currency = txtCurrency.Text.Replace("$", "").Replace(",", "")
That will replace $ and , with empty strings, giving you the format your DB requires
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you very much for your answer. I will try to solve the problem with the above advice
|
|
|
|
|
Hi all,
recently i migrated vb6 to vb.net and in vb.net i have developed an application using MsSql-7 as backend.
now i want to prepare a setup so i can install all needed file to the target computer.
kindly help me as i am new in vb.net, How can i loaded all needed files in setup.
specialy database
i used setup wizard but can't caryy database files
thanks in advance
rmshah
Sr. Developer
|
|
|
|
|
Your issue is, your user needs to install SQL Server ( which is not free, unless you can use the Express Edition ) and then either attach to an existing blank DB, or run a script to create it. It's not as simple as deploying an MDB file.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
can any1 there help mi on a sms program... i am totally new to this so its rather hard for mi.. what i need to do is a restaurant sms system when user sms to this particular no. den it will reply him via a table no.
|
|
|
|
|
Jaysentan wrote: any1
Jaysentan wrote: mi
Jaysentan wrote: den
Most of us are older than 8, please use English.
Why are you using VB6 ? It's outdated, unsupported and it sucks. I know there are webservices around for SMS, but why do you want to use SMS ? How does SMS come into play ? If the user is booking online, why would they need SMS for the number ? You can't run VB6 on a phone, can you ?
When you say you're 'new to this' do you mean VB6 or SMS ? Why are you wanting to write this ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dim index As Integer
index = listbox1.SelectedIndex
listbox1.Items.RemoveAt(index)
The above code is used to remove the seleceted item from a listbox. However the program crashes when the button is clicked and no item is selected. How can I correct??
|
|
|
|
|
Check the value of SelectedIndex before you use it. SelectedItem will be -1 if there is nothing selected.
You might also want to check to see if the number of Items in the Items collection (see it's Count property?) is greater than zero before you try to remove something from it.
|
|
|
|
|
You asked this question yesterday and I answered it[^].
Which part of my advice did you not understand?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Maybe he wants to be sure, but very sure, so he asks to the whole village!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
As the other posters above have stated, SelectedIndex will return -1 if there is nothing selected, so all you have to do is write an IF statement around it.
Dim index As Integer<br />
<br />
index = listbox1.SelectedIndex<br />
If index > -1 Then listbox1.Items.RemoveAt(index)
|
|
|
|
|
Can you help me solve this problem?
I’m using VB.NET 2005 and I’m trying to create a Server Application which can be early bound to by two Client Applications and exchange data between them via the Server Application.
Scenario: There are three applications ClientApp1.exe, ClientApp2.exe & ServerApp.dll all residing on the same server/workstation.
The 2 ClientApps are both manually started and both early bind to the ServerApp.
ClientApp1 sends a message to ClientApp2 via the ServerApp.
ClientApp2 replies to ClientApp1 via the ServerApp.
Do you know how I can create a ServerApp in VB.NET to achieve this?
Every time I create a ServerApp.dll (with a singleton class) and run the two ClientApps they both see different instances of the class.
I think the ClientApps are creating multiple instances of the ServerApp.dll. How do I stop this from happening?
ServerApp.dll
Public Class clsServerApp<br />
Private mstrStartup As String<br />
Private Shared myInstance As clsServerApp<br />
Public Shared ReadOnly Property GetInstance() As clsServerApp<br />
Get<br />
If myInstance Is Nothing Then<br />
myInstance = New clsServerApp<br />
End If<br />
Return myInstance<br />
End Get<br />
End Property<br />
Private Sub New()<br />
mstrStartup = "clsServerApp [Creation Time: " & DateTime.Now.ToString() & "]"<br />
End Sub<br />
Public ReadOnly Property Startup() As String<br />
Get<br />
Return mstrStartup<br />
End Get<br />
End Property<br />
End Class
ClientApp1.exe & ClientApp1.exe
Public Class frmClientApp<br />
Private objServerApp As ServerApp.clsServerApp<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
TextBox1.Text = objServerApp.GetInstance.Startup<br />
End Sub<br />
End Class
Both ClientApp1.exe & ClientApp1.exe early bind to ServerApp.dll but when run both receive different times proving that the singleton class is produces twice...
Regards
Andy
|
|
|
|
|
What does the code look like that's hosting your server object? Are you using a configuration file or creating it in code?? What does that look like??
|
|
|
|
|
Sorry Dave I don't really understand your question as I'm new at this?
I created a new project called ServerApp using a ClassLibrary as a template in VB.NET 2005. Then created a singleton class as in my code snippet in my original mail. Then selected Build ServerApp which created a ServerApp.dll
I then created two test ClientApps (as in my first mail) to read the time the ServerApp was created expecting the same time in both my ClentApps but I was wrong. The ClientApps were early bound to the ServerApp.
Both ClientApps returned different ServerApp creation times suggesting that they were creating their own instance of the ServerApp.
I'm trying to create a ServerApp that can exchange data between bound ClientApps.
Regards
Andy
|
|
|
|
|
Andy Dale wrote: Then selected Build ServerApp which created a ServerApp.dll
The .dll doesn't do you any good if it's not hosted in a 3rd application. The .DLL is being used directly by your client apps. Each is getting it own copy of the .DLL, and hence it's own singleton version of it.
Have you looked into .NET Remoting at all?? Or, if using .NET 3.0, WCF??
|
|
|
|
|
two.My.Settings.turveset = "false"
I want to write data back to my config file with the statement above but get an error message saying "property turveset is readonly". searched help for it but couldnt find how to make it readwrite or something.
help response for error message:
You have tried to assign a value to a property that is declared ReadOnly.
Error ID: BC30526
To correct this error
Remove the ReadOnly specifier from the property declaration.
How to i do that?
|
|
|
|
|
jaska94 wrote: two.My.Settings.turveset = "false"
I want to write data back to my config file with the statement above
You can't do that. The setting you specified is an Application settings and is permanently read-only. You could change the desginer generated code, but any changes you make will be lost.
User settings are Read/Writeable. Application settings are ReadOnly.
If you wanted to change an Application setting, you would proabably have to use the ConfigurationManager class in the System.Configuration namespace, or use the standard XML document classes to manipulate the file. In either case, the setting in the running application will not change until the app is restarted.
|
|
|
|
|
thanks you solved the problem i didnt know that user settings are read/writable so i was looking at wrong direction
|
|
|
|
|
What's the best way to capture all keyboard input for a RichTextBox control? I'm writing a terminal-style application, and so all keyboard input should be sent to the remote device without appearing in the RichTextBox (echoed data, if any, be displayed when it arrives). Putting in a KeyPress handler works, but if the control is not locked people can mess it up by pasting data into it; if it is locked, every keypress results in a "ding" before each KeyPress event. Is there any way to have the control locked but eliminate the "ding"?
|
|
|
|
|
in the keypress event take the key and send it then execute the line e.handled=true
|
|
|
|