|
I am trying to get the Page_load event to dynamically update my checkboxlist values to correspond with the columns in my grid view. the code I have is as follows:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim listItemCount As Integer = -1
Dim totalColNum As Integer = GridView1.Columns.Count
If Page.IsPostBack Then
''Do Something
Else
While listItemCount <= totalColNum
listItemCount += 1
CheckBoxList2.Items.Add(GridView1.Columns(listItemCount).ToString)
End While
End If
End Sub
But I am getting this error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Any ideas??
|
|
|
|
|
Try replacing '<=' with '<' in 'While listItemCount <= totalColNum'. If this doesn't fix it put a break inside the loop and see just how many times you are actually looping through before the error occurs. When the program reaches the break you can hold the mouse over the 'totalColNum' variable and see how many times its trying to loop.
|
|
|
|
|
I figured it out:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim listItemCount As Integer = -1
Dim totalColNum As Integer = GridView1.Columns.Count
Dim valNum As Integer = -1
If Not Page.IsPostBack Then
totalColNum = totalColNum - 1
While listItemCount < -1
listItemCount += 1
valNum += 1
CheckBoxList2.Items.Add(GridView1.Columns(listItemCount).ToString)
CheckBoxList2.Items.Item(listItemCount).Value = valNum.ToString
End While
End If
End Sub
|
|
|
|
|
hi all
can anyone help me in displaying images in a datalist.
images are stored in a folder, not in databse
but the image path is stored in the table
which control shall i use in itemtemplate?
how can i link that control with database?
can anyone help me in detail
thanks in advance
|
|
|
|
|
You can probably add a picturebox to your form and use the PictureBox1.Load(imagepath) function.
|
|
|
|
|
sorry
i want to display in a web form
in a web form , we dont have picturbox, right?
can i use image control?
if yes, how can i set the path?
please help me in solving this
thanks in advance
|
|
|
|
|
I'm sure the image control will work. Scroll through its methods until you find a property or a method that you can use that will allow you to set the image's source, or URL, or path. The image control has some property or method for this. If its a method it will probably be named something like Load. To look through what properties and methods are available type: Image1. where Image1 is the name of your image control. once you press the '.' a list will pop up with all the properties and methods that you can use.
|
|
|
|
|
i want to assemble different web pages of project into different project and asses it as a single project.
omi
|
|
|
|
|
Copy them all the the one folder, and if you have a sln file, add them to it
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I'm using the new report designer. One textbox has a long narration which causes it to spill its information into other textboxes directly below it. How can you stop this from happening?
|
|
|
|
|
I have a just started using VB.NEt and
have a large d drive on my computer and a small c drive.
Is there a way I can tell .Net to use
d drive instead of c drive to store my wwwroot folder?
Can I leave the inetpub folder on c?
CiscoKid55
|
|
|
|
|
You don't have to move your wwwroot. What you can do is create a new folder like d:\temp\blah. "blah" will be the folder containing your web app. Use the IIS admin console to create a new virtual directory called "blah" that points to d:\temp\blah. Then, go to visual studio and create a new web application in http://localhost/blah. It will use the virtual directory you supplied and put the files out on the D drive.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
thanks...
CiscoKid55
|
|
|
|
|
Hi:
I have two panels in a window form and their AutoScroll attributes are set to true. Yet I'd have one panel's HScrollBar or VScrollBar hidden so as to synchronize panel scrolling later.
Could any helper instruct me how to make it? Thanks a lot.
David Ye
|
|
|
|
|
hi!
i have made one master form with toolbar control over it. and i made the modifier of the toolbar to protected so that watever new form which will b inherited from this one can change the properties of this toolbar. but its not working in that way. wat shud b done to get this functionality.
its and desktop application.
thankx in advance.
atif saeed khan
|
|
|
|
|
Hi,
I am creating tmp files everyday written as a Windows service. How would I got about deleting the tmp files from yesterday, would like only the ones created today to exist, which would then be deleted the next day?
Thanks.
-- modified at 10:32 Tuesday 22nd August, 2006
Would this make sense - if midnight then delete all .tmp files?
Thanks
|
|
|
|
|
Yeah, you created them, you should be able to delete them simply once the time rolls over.
|
|
|
|
|
Hello
I am referencing two DLL's from third party build in C# into my project
Both the DLL's have same Types under the same namespace, this is fine with C#
but VB.net does not seems to coupe with this. Is there any way to fix in VB.net?
Thanks
blue
|
|
|
|
|
Try setting the imports statement to direct similar namespaces to an alias that is different. Either that or get to the ambiguous parts using the full namespace path instead.
|
|
|
|
|
Hi guys:
I am trying to compile Porter Stemming VB.NET code but it displays the error below:
The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.
Can anyone help me with this? This code is from official Porter stemming site so the code should be error free. However I cannot compile it with VB 2005. I am new to VB programming so please try to explain with the code below so I know where the error is, thank you very much.
Imports System
Imports System.IO
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
'<Assembly: AssemblyTitle("")>
'<Assembly: AssemblyDescription("Porter stemmer in VB.NET")>
'<Assembly: AssemblyConfiguration("")>
'<Assembly: AssemblyCompany("")>
'<Assembly: AssemblyProduct("")>
'<Assembly: AssemblyCopyright("")>
'<Assembly: AssemblyTrademark("")>
'<Assembly: AssemblyCulture("")>
'<Assembly: AssemblyVersion("1.4")>
'<Assembly: AssemblyKeyFile("keyfile.snk")>
'<Assembly: AssemblyDelaySign(False)>
'<Assembly: AssemblyKeyName("")>
Namespace PorterStemmerAlgorithm
'
' Porter stemmer in VB.NET, translation of the CSharp port (csharp2.txt).
' The original paper is in
' Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14,
' no. 3, pp 130-137,
' See also http://www.tartarus.org/~martin/PorterStemmer
' History:
' Release 1
' Bug 1 (reported by Gonzalo Parra 16/10/99) fixed as marked below.
' The words 'aed', 'eed', 'oed' leave k at 'a' for step 3, and b[k-1]
' is then out outside the bounds of b.
' Release 2
' Similarly,
' Bug 2 (reported by Steve Dyrdahl 22/2/00) fixed as marked below.
' 'ion' by itself leaves j = -1 in the test for 'ion' in step 5, and
' b[j] is then outside the bounds of b.
' Release 3
' Considerably revised 4/9/00 in the light of many helpful suggestions
' from Brian Goetz of Quiotix Corporation (brian@quiotix.com).
' Release 4
' This revision allows the Porter Stemmer Algorithm to be exported via the
' .NET Framework. To facilate its use via .NET, the following commands need to be
' issued to the operating system to register the component so that it can be
' imported into .Net compatible languages, such as Delphi.NET, Visual C#.NET,
' Visual C++.NET, etc.
' 1. Create a stong name:
' sn -k Keyfile.snk
' 2. Compile the VB.NET class, which creates an assembly PorterStemmerAlgorithm.dll
' vbc /t:library PorterStemmerAlgorithm.vb
' 3. Register the dll with the Windows Registry
' and so expose the interface to COM Clients via the type library
' ( PorterStemmerAlgorithm.tlb will be created)
' regasm /tlb PorterStemmerAlgorithm.dll
' 4. Load the component in the Global Assembly Cache
' gacutil -i PorterStemmerAlgorithm.dll
' Note: You must have the .Net Studio installed.
' Once this process is performed you should be able to import the class
' via the appropiate mechanism in the language that you are using.
' i.e in Delphi 7 .NET this is simply a matter of selecting:
' Project | Import Type Libary
' And then selecting Porter stemmer in VB.NET Version 1.4"!
' Stemmer, implementing the Porter Stemming Algorithm
'
' The Stemmer class transforms a word into its root form. The input
' word can be provided a character at time (by calling add()), or at once
' by calling one of the various stem(something) methods.
'
Public Interface StemmerInterface
Function stemTerm(ByVal s As String) As String
End Interface
<ClassInterface(ClassInterfaceType.None)> Public Class PorterStemmer
Implements StemmerInterface
Public b As Char()
Private i As Integer ' offset into b
Private i_end As Integer ' offset to end of stemmed word
Private j, k As Integer
Private Shared INC As Integer = 200 ' unit of size whereby b is increased
Public Sub New()
b = New Char(INC) {}
i = 0
i_end = 0
End Sub
' Implementation of the .NET interface - added as part of release 4 (Leif)
Public Function stemTerm(ByVal s As String) As String Implements StemmerInterface.stemTerm
setTerm(s)
stem()
Return getTerm()
End Function
' SetTerm and GetTerm have been simply added to ease the
' interface with other lanaguages. They replace the add functions
' and toString function. This was done because the original functions stored
' all stemmed words (and each time a new woprd was added, the buffer would be
' re-copied each time, making it quite slow). Now, The class interface
' that is provided simply accepts a term and returns its stem,
' instead of storing all stemmed words.
' (Leif)
Private Sub setTerm(ByVal s As String)
i = s.Length
Dim new_b As Char() = New Char(i) {}
Dim c As Integer
For c = 0 To (i - 1)
new_b(c) = s.Chars(c)
Next
b = new_b
End Sub
Private Function getTerm() As String
Return New String(b, 0, i_end)
End Function
' Old interface to the class - left for posterity. However, it is not
' used when accessing the class via .NET (Leif)*/
'
' Add a character to the word being stemmed. When you are finished
' adding characters, you can call stem(void) to stem the word.
'
Public Sub add(ByVal ch As Char)
Dim c As Integer
If (i = b.Length) Then
Dim new_b As Char() = New Char(i + INC) {}
For c = 0 To (i - 1) Step 1
new_b(c) = b(c)
Next
b = new_b
End If
b(i) = ch
i = i + 1
End Sub
' Adds wLen characters to the word being stemmed contained in a portion
' of a char[] array. This is like repeated calls of add(char ch), but
' faster.
Public Sub add(ByVal w As Char(), ByVal wLen As Integer)
Dim c As Integer
If i + wLen >= b.Length Then
Dim new_b As Char() = New Char(i + wLen + INC) {}
For c = 0 To (i - 1) Step 1
new_b(c) = b(c)
Next
b = new_b
End If
For c = 0 To (wLen - 1) Step 1
b(i) = w(c)
i = i + 1
Next
End Sub
' After a word has been stemmed, it can be retrieved by toString(),
' or a reference to the internal buffer can be retrieved by getResultBuffer
' and getResultLength (which is generally more efficient.)
Public Overrides Function ToString() As String
Return New String(b, 0, i_end)
End Function
' Returns the length of the word resulting from the stemming process.
Public Function getResultLength() As Integer
Return i_end
End Function
' Returns a reference to a character buffer containing the results of
' the stemming process. You also need to consult getResultLength()
' to determine the length of the result.
Public Function getResultBuffer() As Char()
Return b
End Function
' cons(i) is true <=> b is a consonant.
Public Function cons(ByVal i As Integer) As Boolean
Select Case b(i)
Case "a"c ' Cast string to char. Option Strict On.
Case "e"c
Case "i"c
Case "o"c
Case "u"c
Return False
Case "y"c
If i = 0 Then
Return True
Else
Return Not (cons(i - 1))
End If
Case Else
Return True
End Select
End Function
' m() measures the number of consonant sequences between 0 and j. if c is
' a consonant sequence and v a vowel sequence, and <..> indicates arbitrary
' presence,
' <c><v> gives 0
' <c>vc<v> gives 1
' <c>vcvc<v> gives 2
' <c>vcvcvc<v> gives 3
' ....
'
Private Function m() As Integer
Dim n As Integer = 0
Dim i As Integer = 0
While True
If (i > j) Then Return n
If (Not cons(i)) Then Exit While
i = i + 1
End While
i = i + 1
While (True)
While (True)
If (i > j) Then Return n
If (cons(i)) Then Exit While
i = i + 1
End While
i = i + 1
n = n + 1
While (True)
If (i > j) Then Return n
If (Not cons(i)) Then Exit While
i = i + 1
End While
i = i + 1
End While
End Function
' vowelinstem() is true <=> 0,...j contains a vowel
Private Function vowelinstem() As Boolean
Dim i As Integer
For i = 0 To j Step 1 ' i <= j
If (Not cons(i)) Then Return True
Next
Return False
End Function
' doublec(j) is true <=> j,(j-1) contain a double consonant.
Private Function doublec(ByVal j As Integer) As Boolean
If (j < 1) Then Return False
If (b(j) <> b(j - 1)) Then Return False
Return cons(j)
End Function
' cvc(i) is true <=> i-2,i-1,i has the form consonant - vowel - consonant
' and also if the second c is not w,x or y. this is used when trying to
' restore an e at the end of a short word. e.g.
'
' cav(e), lov(e), hop(e), crim(e), but
' snow, box, tray.
'
Private Function cvc(ByVal i As Integer) As Boolean
If ((i < 2) OrElse (Not cons(i)) OrElse cons(i - 1) OrElse (Not cons(i - 2))) Then
Return False
End If
Dim ch As Char = b(i)
If (ch = "w"c OrElse ch = "x"c OrElse ch = "y"c) Then Return False
Return True
End Function
Private Function ends(ByVal s As String) As Boolean
Dim l As Integer = s.Length
Dim o As Integer = k - l + 1
If (o < 0) Then Return False
Dim sc As Char() = s.ToCharArray
Dim i As Integer
For i = 0 To (l - 1) Step 1
If (b(o + i) <> sc(i)) Then Return False
Next
j = k - l
Return True
End Function
' setto(s) sets (j+1),...k to the characters in the string s, readjusting
' k.
Private Sub setto(ByVal s As String)
Dim l As Integer = s.Length
Dim o As Integer = j + 1
Dim sc As Char() = s.ToCharArray
For i = 0 To (l - 1) Step 1
b(o + i) = sc(i)
Next
k = j + l
End Sub
' r(s) is used further down.
Private Sub r(ByVal s As String)
If (m() > 0) Then setto(s)
End Sub
' step1() gets rid of plurals and -ed or -ing. e.g.
' caresses -> caress
' ponies -> poni
' ties -> ti
' caress -> caress
' cats -> cat
'
' feed -> feed
' agreed -> agree
' disabled -> disable
'
' matting -> mat
' mating -> mate
' meeting -> meet
' milling -> mill
' messing -> mess
'
' meetings -> meet
'
Private Sub step1()
If (b(k) = "s"c) Then
If (ends("sses")) Then
k = k - 2
ElseIf (ends("ies")) Then
setto("i")
ElseIf (b(k - 1) <> "s"c) Then
k = k - 1
End If
End If
If (ends("eed")) Then
If (m() > 0) Then
k = k - 1
End If
ElseIf ((ends("ed") OrElse ends("ing")) AndAlso vowelinstem()) Then
k = j
If (ends("at")) Then
setto("ate")
ElseIf (ends("bl")) Then
setto("ble")
ElseIf (ends("iz")) Then
setto("ize")
ElseIf (doublec(k)) Then
k = k - 1
Dim ch As Char = b(k)
If ((ch = "l"c) OrElse (ch = "s"c) OrElse (ch = "z"c)) Then
k = k + 1
End If
ElseIf ((m() = 1) AndAlso cvc(k)) Then
setto("e")
End If
End If
End Sub
' step2() turns terminal y to i when there is another vowel in the stem.
Private Sub step2()
If (ends("y") AndAlso vowelinstem()) Then
b(k) = "i"c
End If
End Sub
' step3() maps double suffices to single ones. so -ization ( = -ize plus
' -ation) maps to -ize etc. note that the string before the suffix must give
' m() > 0.
Private Sub step3()
If (k = 0) Then Return
'For Bug 1
Select Case (b(k - 1))
Case "a"c
If ends("ational") Then
r("ate")
Exit Select
End If
If ends("tional") Then
r("tion")
Exit Select
End If
Exit Select
Case "c"c
If ends("enci") Then
r("ence")
Exit Select
End If
If ends("anci") Then
r("ance")
Exit Select
End If
Exit Select
Case "e"c
If ends("izer") Then
r("ize")
Exit Select
End If
Exit Select
Case "l"c
If ends("bli") Then
r("ble")
Exit Select
End If
If ends("alli") Then
r("al")
Exit Select
End If
If ends("entli") Then
r("ent")
Exit Select
End If
If ends("eli") Then
r("e")
Exit Select
End If
If ends("ousli") Then
r("ous")
Exit Select
End If
Exit Select
Case "o"c
If ends("ization") Then
r("ize")
Exit Select
End If
If ends("ation") Then
r("ate")
Exit Select
End If
If ends("ator") Then
r("ate")
Exit Select
End If
Exit Select
Case "s"c
If ends("alism") Then
r("al")
Exit Select
End If
If ends("iveness") Then
r("ive")
Exit Select
End If
If ends("fulness") Then
r("ful")
Exit Select
End If
If ends("ousness") Then
r("ous")
Exit Select
End If
Exit Select
Case "t"c
If ends("aliti") Then
r("al")
Exit Select
End If
If ends("iviti") Then
r("ive")
Exit Select
End If
If ends("biliti") Then
r("ble")
Exit Select
End If
Exit Select
Case "g"c
If ends("logi") Then
r("log")
Exit Select
End If
Exit Select
Case Else
Exit Select
End Select
End Sub
' step4() deals with -ic-, -full, -ness etc. similar strategy to step3.
Private Sub step4()
Select Case (b(k))
Case "e"c
If ends("icate") Then
r("ic")
Exit Select
End If
If ends("ative") Then
r("")
Exit Select
End If
If ends("alize") Then
r("al")
Exit Select
End If
Exit Select
Case "i"c
If ends("iciti") Then
r("ic")
Exit Select
End If
Exit Select
Case "l"c
If ends("ical") Then
r("ic")
Exit Select
End If
If ends("ful") Then
r("")
Exit Select
End If
Exit Select
Case "s"c
If ends("ness") Then
r("")
Exit Select
End If
Exit Select
End Select
End Sub
' step5() takes off -ant, -ence etc., in context <c>vcvc<v>.
Private Sub step5()
If (k = 0) Then Return
' for Bug 1
Select Case (b(k - 1))
Case "a"c
If ends("al") Then
Exit Select
End If
Return
Case "c"c
If ends("ance") Then
Exit Select
End If
If ends("ence") Then
Exit Select
End If
Return
Case "e"c
If ends("er") Then
Exit Select
End If
Return
Case "i"c
If ends("ic") Then
Exit Select
End If
Return
Case "l"c
If ends("able") Then
Exit Select
End If
If ends("ible") Then
Exit Select
End If
Return
Case "n"c
If ends("ant") Then
Exit Select
End If
If ends("ement") Then
Exit Select
End If
If ends("ment") Then
Exit Select
End If
' element etc. not stripped before the m
If ends("ent") Then
Exit Select
End If
Return
Case "o"c
If ends("ion") AndAlso (j >= 0) AndAlso (b(j) = "s"c OrElse b(j) = "t"c) Then
' j >= 0 fixes Bug 2
Exit Select
End If
If ends("ou") Then
Exit Select
End If
Return
'takes care of -ous
Case "s"c
If ends("ism") Then
Exit Select
End If
Return
Case "t"c
If ends("ate") Then
Exit Select
End If
If ends("iti") Then
Exit Select
End If
Return
Case "u"c
If ends("ous") Then
Exit Select
End If
Return
Case "v"c
If ends("ive") Then
Exit Select
End If
Return
Case "z"c
If ends("ize") Then
Exit Select
End If
Return
Case Else
Return
End Select
If (m() > 1) Then k = j
End Sub
' step6() removes a final -e if m() > 1.
Private Sub step6()
j = k
If (b(k) = "e"c) Then
Dim a As Integer = m()
If (a > 1) OrElse ((a = 1) AndAlso (Not cvc(k - 1))) Then k = k - 1
End If
If (b(k) = "l"c) AndAlso doublec(k) AndAlso (m() > 1) Then k = k - 1
End Sub
' Stem the word placed into the Stemmer buffer through calls to add().
' Returns true if the stemming process resulted in a word different
' from the input. You can retrieve the result with
' getResultLength()/getResultBuffer() or toString().
'
Public Sub stem()
k = i - 1
If (k > 1) Then
step1()
step2()
step3()
step4()
step5()
step6()
End If
i_end = k + 1
i = 0
End Sub
End Class
End Namespace
-- modified at 10:14 Tuesday 22nd August, 2006
|
|
|
|
|
I'll share a very unconventional method that professionals have secretly used for years:
Do exactly as the error message says.
Move the code for the form class so that it's the first class in the file.
---
b { font-weight: normal; }
|
|
|
|
|
please tell me how to install or use webcam in Vb 6.0 and how to save images in ms access through vb. im developing a system now and it needs to use webcam to capture and store pictures.
thanks!!!!!
adikkaymonic
|
|
|
|
|
Hi all,
Im using a windows form and on mouse down on a label i want to draw an rectangle on the label. Its working fine when the label without border. But When i have the label with border, after clicking the label for the fisrt time its throwing "System.Runtime.InteropServices.ExternalException" . and an Generic GDI+ Error.
In DrawRectangle function i removed the border of the control by converting the control to a label inroder to have that BorderStyle Property. I think problem might have occured in this line of code.
and its not drawing the rectangle, for the second time mouse down, its working fine and draws the rectangle properly.
Whats could be the problem, Please guide me. I was struggling with this error for the past two days. Code is given below.
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
If CInt(Label1.Tag) = 0 Then
Label1.Tag = 1
DrawRectAngle(Label1)
ElseIf CInt(Label1.Tag) = 1 Then
Label1.Tag = 2
Label1.Refresh()
DrawCrossLine(Label1)
Else
Label1.Tag = 0
Label1.Refresh()
End If
End Sub
Private Sub DrawRectAngle(ByVal ControlName As Control)
Dim RectPen As New Pen(Color.Lime)
RectPen.Width = 6
g = ControlName.CreateGraphics()
Try
If TypeOf ControlName Is System.Windows.Forms.Label Then
CType(ControlName, Label).BorderStyle = BorderStyle.None
End If
Dim rect As Rectangle
rect = New Rectangle(1, 1, ControlName.Width, ControlName.Height)
g.DrawRectangle(RectPen, rect)
Catch ex As Exception
End Try
End Sub
Regards
Mukilan.
|
|
|
|
|
hi!
im new to vb.net. and lookin for help frm u all genius working in .net
i have seen the showpopup method, this is very nice thing in .net now good to c such thing for quick help. i have tried the example from msdn, i thot from example that the showpopup will show help on the bottom of the textbox but unfortunately it is not working that way. it is showin somewhere else on the form.if i do maximize the form the location also changes. so plz let me knw is there anyprob for this popup help showing location or is there anything im doing wrong. i have seen one topic in this website too on this. in this topic they have used mousepointer position to showpopup help. that is working fine. wherever the cursor is system show that popup on that place but i wana to show that quick help popup on the textbox or anycontrol bottom side as example in msdn is saying.
thankx in advance and help will b v v appreciate.
atif saeed khan
software developer
realtime technology
dubai
|
|
|
|
|