Click here to Skip to main content
16,017,857 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Translation to VB Pin
Dave Doknjas11-Jul-09 14:34
Dave Doknjas11-Jul-09 14:34 
QuestionAccess to the path 'Global\.net clr networking' is denied Pin
Anubhava Dimri11-Jul-09 0:44
Anubhava Dimri11-Jul-09 0:44 
AnswerRe: Access to the path 'Global\.net clr networking' is denied Pin
Christian Graus11-Jul-09 2:21
protectorChristian Graus11-Jul-09 2:21 
GeneralRe: Access to the path 'Global\.net clr networking' is denied Pin
Anubhava Dimri12-Jul-09 18:10
Anubhava Dimri12-Jul-09 18:10 
QuestionI want to click a link in the web page [modified] Pin
pobre1210-Jul-09 23:25
pobre1210-Jul-09 23:25 
Questionsomething like windows vista sidebar or google sidebar Pin
Ali Hojjati10-Jul-09 21:15
Ali Hojjati10-Jul-09 21:15 
AnswerRe: something like windows vista sidebar or google sidebar Pin
Henry Minute11-Jul-09 0:44
Henry Minute11-Jul-09 0:44 
QuestionCan't get combo box to update with data [modified] Pin
Dominick Marciano10-Jul-09 8:01
professionalDominick Marciano10-Jul-09 8:01 
I writing a program that is used for data entry for my company. On the main form there is a combo box that is full of different components we may test; things such as doors, window, closets, etc. This is list of components is store in a file in the program's directory and loaded when the program loads and all the different components are put into the combo box. This works fine. Now, when an inspector is in the field they may need to add a component not pre-programmed in. So they can go to another form and add the different components. Once they are finished enter any components they may need to add they click a command button "Done" that then saves the new components to a file:

<pre>
'Check if there are structures in the 'lstStructures' list box
If lstStructures.Items.Count &gt; 0 Then

'Create a new file stream
Dim fs As FileStream = New FileStream(AppPath &amp; "\" &amp; StructureFile, FileMode.Truncate, FileAccess.Write, FileShare.None)
'Create a new stream writer
Dim Writer As StreamWriter = New StreamWriter(fs)

'Loop through each component in the 'ComponentArray' array list
For i As Integer = 0 To ComponentArray.Count - 1
'Save current component in the 'CurrentComponent' structure
CurrentComponent = ComponentArray.Item(i)
'Write the component/member string to the stream writer
'(Structure=Member1,Member2,...,MemberN)
Writer.WriteLine(CurrentComponent.ComponentStructure &amp; "=" &amp; CurrentComponent.ComponentMember)
Next

'Flush the stream writer
Writer.Flush()
'Close the stream writer
Writer.Close()
'Close the file stream
fs.Close()
'Close this form
Me.Hide()
End If

FL_ADDED_NEW_STRUCTURE = True
'Load the structures on the main form
frmMain.ReLoadCustoms()
</pre>

Now the <code>frmMain.ReLoadCustoms</code> should reload the file with the newly added components and add them to the combo box:

<pre>
Public Sub ReLoadCustoms()

Dim fs As FileStream
Dim Reader As StreamReader
Dim div() As String

fs = New FileStream(AppPath &amp; "\" &amp; StructureFile, FileMode.Open, FileAccess.Read, FileShare.None)

'Clear Component Array
ComponentArray.Clear()

'Check if the file is empty
If Not fs.Length = 0 Then
'Create a new stream reader
Reader = New StreamReader(fs)

'Read each line of the file until the end of the file
Do Until Reader.EndOfStream
'Split each line delimited with '='
'(Structure=Member1,Member2,...,MemberN)
div = Reader.ReadLine.Split("=")
CurrentComponent.ComponentStructure = div(0)
CurrentComponent.ComponentMember = div(1)
'Save the component in the 'ComponentArray' array list
ComponentArray.Add(CurrentComponent)
Loop
'Close the stream reader
Reader.Close()
'Close the file stream
fs.Close()
End If

cboStructures.Items.Clear()

For i As Integer = 0 To ComponentArray.Count - 1
CurrentComponent = ComponentArray.Item(i)
cboStructures.Items.Add(CurrentComponent.ComponentStructure)
Next

cboStructures.Items.Add("...Add...")
cboStructures.SelectedIndex = 0

cboMembers.Items.Clear()
CurrentComponent = ComponentArray.Item(0)
div = CurrentComponent.ComponentMember.Split(",")
For i As Integer = 0 To div.GetUpperBound(0)
cboMembers.Items.Add(div(i))
Next

cboMembers.SelectedIndex = 0
cboStructures.Update()


FL_ADDED_NEW_STRUCTURE = False

End Sub
</pre>

The problem is that the new components that were added do not show up in the combo box, but they are written to the file. I have verified this by looking at the component file and because the next time the program loads the new components are present...the problem is that the whole program needs to be reloaded for some reason. Any help would be greatly appreciated as this has been driving me crazy for over a month! Thanks in advanced.

P.S. The <code>ReLoadCustoms</code> sub is on <code>frmMain</code> and the <code>SaveFile</code> sub is on <code>frmStructures</code> and this is running on a PPC.

UPDATE: I have come to realize that for some reason the cboStructures.Items.Clear in the ReLoadCustoms does not actually clear the combo box. Any suggestions?

modified on Friday, July 10, 2009 2:45 PM

AnswerRe: Can't get combo box to update with data Pin
Henry Minute10-Jul-09 10:45
Henry Minute10-Jul-09 10:45 
QuestionRe: Can't get combo box to update with data Pin
Dominick Marciano16-Jul-09 7:18
professionalDominick Marciano16-Jul-09 7:18 
AnswerRe: Can't get combo box to update with data Pin
Henry Minute17-Jul-09 0:03
Henry Minute17-Jul-09 0:03 
QuestionPrinting in .net Pin
No-e10-Jul-09 7:55
No-e10-Jul-09 7:55 
AnswerRe: Printing in .net Pin
Henry Minute10-Jul-09 11:16
Henry Minute10-Jul-09 11:16 
GeneralRe: Printing in .net Pin
No-e10-Jul-09 11:45
No-e10-Jul-09 11:45 
QuestionFind a 16bit Process Pin
nlarson1110-Jul-09 4:01
nlarson1110-Jul-09 4:01 
AnswerRe: Find a 16bit Process Pin
Dave Kreskowiak10-Jul-09 9:47
mveDave Kreskowiak10-Jul-09 9:47 
GeneralRe: Find a 16bit Process Pin
nlarson1110-Jul-09 9:55
nlarson1110-Jul-09 9:55 
QuestionGoogle Earth in Web Application with adress search capabilities Pin
Member 442053410-Jul-09 3:38
Member 442053410-Jul-09 3:38 
AnswerRe: Google Earth in Web Application with adress search capabilities Pin
DoctorMick10-Jul-09 4:55
DoctorMick10-Jul-09 4:55 
AnswerRe: Google Earth in Web Application with adress search capabilities Pin
DoctorMick10-Jul-09 5:03
DoctorMick10-Jul-09 5:03 
QuestionHow to convert number to indian rupees format text in crystal report??? Pin
JC.KaNNaN9-Jul-09 21:25
JC.KaNNaN9-Jul-09 21:25 
AnswerRe: How to convert number to indian rupees format text in crystal report??? Pin
Nagy Vilmos9-Jul-09 21:58
professionalNagy Vilmos9-Jul-09 21:58 
GeneralRe: How to convert number to indian rupees format text in crystal report??? Pin
JC.KaNNaN9-Jul-09 22:15
JC.KaNNaN9-Jul-09 22:15 
GeneralRe: How to convert number to indian rupees format text in crystal report??? Pin
Nagy Vilmos10-Jul-09 1:03
professionalNagy Vilmos10-Jul-09 1:03 
QuestionMoves data From Program Files in VISTA Pin
Anubhava Dimri9-Jul-09 21:14
Anubhava Dimri9-Jul-09 21:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.