|
Module Module1
Sub Main()
Dim txt As String = ""
Dim arr() As Double = {20, 11, 34, 25, 55, 89}
Dim tot As Double = 0
For i As Integer = 0 To 5
If i < 5 Then
txt &= arr(i).ToString("0")
txt &= "+"
tot += arr(i)
Else
txt &= arr(i)
txt &= "="
tot += arr(i)
txt &= tot.ToString("0")
End If
Next
Console.WriteLine("Output: {0}", txt)
Console.Read()
End Sub
End Module
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
We have a windows project in VB.NET 8 (2005) for a couple of years.
Now it just seems that the modules and code behind forms have a colon and a number after them in the tabs with the name. i.e. module was frmWebUpload.vb now shows in tab as frmWebUpload.vb:1 and frmWebUpload.vb:2
In addition, when editing these modules with the colon then the events and procuderes have empty in them. The normal modules would have a functional drop down.
Can anyone tell me why and how to fix it?
Thanks
|
|
|
|
|
I wonder if that is the designer and code files separated. There is a button at the top of the solution explorer that turns on or off show all files I think if you have this on the files will show as you are saying and not otherwise.
Humble Programmer
|
|
|
|
|
Hi guys,
I don't know if you already seen this video about Visual Studio 2010, but I think it's pretty useful meanwhile MSDN subscription arrive.
|
|
|
|
|
|
Probably best to have posted this in the appropriate forum.
|
|
|
|
|
Hi,
I want to disable users mailbox account from exchange server 2007 using vb.net
I have tried to add CDOEXM.dll but its not added..
thanks in advance
|
|
|
|
|
CDOEXM is not available for exchange 2007. It's now a separate download .[^]
Note that support for cdo is being phased out starting this month.
You should also grab hold of a copy of the exchange admin tools (probably for 32 bit) for exchange 2007, and install them on the system where the programs will be running... Your pc should be part of the same active directory domain as your exchange server.
I strongly suggest you use the new powershell interface for doing your stuff, as this will not work anymore on exchange 2010...
|
|
|
|
|
Hi All,
I have 600 rows entries in a SQL database column "Name".
At present I am looping through each row and searching for a text which should match the entries in "Name" column.
My code is like this:
For Each dr As DataRow In myDataSet.Tables(0).Rows
If Trim(dr(("Name"))) = Trim(search_text) Then
' matching found...
End If
Next
above, myDataSet contains the "Name" column data.
Now, the above code is very time consuming, because it has to loop entire 600 times...
What I am looking is any simple method, by which it direct jumps into the matched row and read the entries.
Can someone suggest me how to do this?
Regards,
R.S
|
|
|
|
|
|
Ever heard of the SQL 'LIKE' clause ?
|
|
|
|
|
The DataTable object has a .Select in which you can specify what would a WHERE portion of SQL and it will return an array of DataRows. This way you can pull a lot of data from a database just once, then filter it different ways quickly when you get it back. For your code above it would work something like this:
For Each row As DataRow In myDataSet.Tables(0).Select("Name='" & search_text & "'")
Next
|
|
|
|
|
Need some advice on which would be better!
1. creating a function that take a list(of sqlparameters)
<br />
Dim ParamList As New List(Of SqlParameter)<br />
<br />
Dim param As New SqlParameter("@SectionNo", SqlDbType.Int)<br />
param.Value = SectionNo<br />
<br />
ParamList.Add(param)<br />
or
2. Creating a data dictionary storing parameter name, type and value and then building up a sqlparametercollection e.g.
<br />
dim pc as sqlparametercollection<br />
pc = da.selectcommand.parameters<br />
for each entry in the datadictionary<br />
pc.add(paramName, Type, value)<br />
next<br />
reason for asking i need to created a stored proc that could have upto 100 parameters and am looking for speed and re-useability.
Many Thanks for your help and hope it makes sense
Simon
|
|
|
|
|
Simon_Whale wrote: i need to created a stored proc that could have upto 100 parameters
|
|
|
|
|
|
the information is for an insurance underwriting system. I've tried to argue the case with the lead developer that we should split the data up in the logic layer and insert into the database in smaller chunks, but it failed.
So im trying to make sure that the data layer works the most efficient and reliable way possible and then argue about the way data is handled later down the road.
|
|
|
|
|
The lead developer should then be fired for incompetence. Not processing in smaller chunks so that the code is more maintainable is just ludicrous.
Simon_Whale wrote: argue about the way data is handled later down the road.
Why? So you have to redevelop the data layer at a later time? Trust me. It's never going to happen.
|
|
|
|
|
Simon_Whale wrote: a stored proc that could have upto 100 parameters
maybe store your parameters in the database then?
|
|
|
|
|
When I click a button in my program some text pops up in a label. Is there a way to automatically clear/erase the text 5 seconds after clicking the button?
|
|
|
|
|
Use a Timer control. Start the timer in the click event of the Button and in the Tick event of the Timer, clear the content of the TextBox and stop the timer.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Alright thank you Im new to this so I didnt even know about that.
|
|
|
|
|
That is why we are here, I still ask.
Always nice to Vote Up a helpful response though
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
A ToolTip didn't work for what you wanted?
|
|
|
|
|
Experts,
Initally what i want to do is to sort 2 lots of data. 1 sort would be the highscore (the highest of the score, ad the second dort would be through the time (lowest).
I dont't really know what the best way to do this, so that was why i thought i would ask you lot. I also will post up the code i am having a bit of trouble with. This may be able to cope with what i am wanting to do.
I am using 1 button called comtest
2 list boxes called listBox1 and ListBox2
2 textboxes called text1 and text2
Imports System.IO
Public Class Form1
Dim scores = New System.Collections.Generic.List(Of String)
Dim names = New System.Collections.Generic.List(Of String)
Dim test1(0 To 10) As String
Dim test2(0 To 10) As Integer
Dim userscore As Integer
Dim username As String
Dim a As Integer
Dim b As Integer
Dim i As Integer
Dim strFilename As String = ("High Scores.txt")
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call highscore()
names = New System.Collections.Generic.List(Of String)
scores = New System.Collections.Generic.List(Of Integer)
Dim srScores As New IO.StreamReader(strFilename)
While Not srScores.EndOfStream
Dim strRead As String = srScores.ReadLine
ListBox1.Items.Add(strRead)
Dim strSplit() As String = Split(strRead, ",")
names.Add(strSplit(0))
scores.Add(strSplit(1))
End While
srScores.Close()
End Sub
Private Sub comtest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comtest.Click
username = Text1.Text
userscore = Val(Text2.Text)
For i = 1 To 10
a = scores(i)
If userscore >= a Then
test1(i) = username
test2(i) = userscore
For b = i + 1 To 10
test1(b) = names(b - 1)
test2(b) = scores(b - 1)
Next
Call newscore()
Exit Sub
End If
test1(i) = names(i)
test2(i) = scores(i)
Next
End Sub
Private Sub highscore()
For i = 1 To 10
ListBox1.Items.Add(names(i)) 'this always comes up with an error saying argument out of range
List2.Items.Add(scores(i))
Next
End Sub
Private Sub newscore() ' write
ListBox1.ClearSelected()
List2.ClearSelected()
For i = 1 To 10
ListBox1.Items.Add(test1(i))
List2.Items.Add(test2(i))
names(i) = test1(i)
scores(i) = test2(i)
Next
Dim objWriter As New System.IO.StreamWriter(highScoresFile)
For i = 1 To 10
objWriter.Write(names(i) & "," & scores(i))
Next
objWriter.Close()
End Sub
If anybody can help that would be great
Many thanks
Dan
|
|
|
|
|
There are several problems in your program
- you defined names = New System.Collections.Generic.List(Of String) in the declarations section and later on in Form_Load you have scores = New System.Collections.Generic.List(Of Integer) . Is the list of type Integer or String?
- you are trying to load the listboxes with names/scores before you read them from the textfile. so move the line Call highscore to the bottom in Form1_Load
- in Sub highscore you are loading the listboxes from the names/scores lists. The entries in the list are indexed from 0 to Count-1. So change the first line to For i = 0 To 9
there are probably several more problems but this should get you started.
Tosch
|
|
|
|