i keep getting out of range exception when i run my code in vb..
it says that
HslSubj = Struktur(PosKt - 1)
is out of range exception unhandled..
but if i delete that i get a new error, which is argument exception.. please help me fix it..
i put my whole code below.. - Public Class FrMain
-
Public KDasar(0 To 9, 0 To 1) As String
-
Public Imbuh(0 To 4, 0 To 1) As String
-
Public Struktur(0 To 3) As String
-
Public DesStruktur(0 To 3) As String
-
-
Private Class KataDasar
-
Private pVal As String, pValint As Integer
-
Public Property description() As String
-
Get
-
Return pVal
-
End Get
-
Set(ByVal value As String)
-
pVal = value
-
End Set
-
End Property
-
Public Property groupID() As Integer
-
Get
-
Return pValint
-
End Get
-
Set(ByVal value As Integer)
-
pValint = value
-
End Set
-
End Property
-
End Class
-
-
Private Class StrukKalimat
-
Private pVal As String, pVal2 As Integer
-
Public Property teks() As String
-
Get
-
Return pVal
-
End Get
-
Set(ByVal value As String)
-
pVal = value
-
End Set
-
End Property
-
Public Property IDstring() As String
-
Get
-
Return pVal2
-
End Get
-
Set(ByVal value As String)
-
pVal2 = value
-
End Set
-
End Property
-
End Class
-
-
Sub InisialisasiDB()
-
Imbuh(0, 0) = "men"
-
Imbuh(1, 0) = "kan"
-
Imbuh(2, 0) = "mem"
-
Imbuh(3, 0) = "di"
-
Imbuh(4, 0) = "ber"
-
-
Imbuh(0, 1) = "0"
-
Imbuh(1, 1) = "1"
-
Imbuh(2, 1) = "0"
-
Imbuh(3, 1) = "0"
-
Imbuh(4, 1) = "0"
-
-
KDasar(0, 0) = "dengar"
-
KDasar(1, 0) = "simpan"
-
KDasar(2, 0) = "belanja"
-
KDasar(3, 0) = "baca"
-
-
KDasar(0, 1) = "1"
-
KDasar(1, 1) = "1"
-
KDasar(2, 1) = "1"
-
KDasar(3, 1) = "1"
-
-
KDasar(4, 0) = "sekarang"
-
KDasar(5, 0) = "dipasar"
-
KDasar(6, 0) = "hariini"
-
KDasar(7, 0) = "dilemari"
-
KDasar(8, 0) = "siangini"
-
-
KDasar(4, 1) = "3"
-
KDasar(5, 1) = "3"
-
KDasar(6, 1) = "3"
-
KDasar(7, 1) = "3"
-
KDasar(8, 1) = "3"
-
-
KDasar(9, 0) = "mainan"
-
KDasar(9, 1) = "0"
-
-
Struktur(0) = "Subyek"
-
Struktur(1) = "Predikat"
-
Struktur(2) = "Objek"
-
Struktur(3) = "Keterangan"
-
-
DesStruktur(0) = "Subjek berupa kata benda (nomina)"
-
DesStruktur(1) = "Predikat berupa kata kerja (verba)"
-
DesStruktur(2) = "Objek berupa kata benda (nomina)"
-
DesStruktur(3) = "Keterangan berupa keterangan waktu atau tempat"
-
-
End Sub
-
-
Function StateMachine1(ByVal kal As String) As String
-
Dim HslString As String, HslKet As String, HslPred As String, HslSubj As String
-
Dim HslObjek As String, hslImbuhan As String
-
Dim pch() As String = Split(kal, " ")
-
Dim A As Integer, e As Integer = -1, u As Integer, k As Integer, PosKt As Integer
-
Dim PosKt1 As Integer
-
-
For u = 0 To UBound(pch)
-
For A = 0 To UBound(Imbuh)
-
e = InStr(1, pch(u), Imbuh(A, 0), CompareMethod.Text)
-
If (e > 0) And (e < Len(pch(u)) - 3) Then
-
If Imbuh(A, 1) = "0" Then hslImbuhan = hslImbuhan & Imbuh(A, 0) & "!"
-
ElseIf e <> 0 Then
-
If e = Len(pch(u)) - (Len(Imbuh(A, 0)) + 1) Then
-
If Imbuh(A, 1) = "1" Then hslImbuhan = hslImbuhan & Imbuh(A, 0) & "!"
-
End If
-
End If
-
Next A
-
Next u
-
-
For k = 1 To 2
-
For u = 0 To UBound(pch)
-
For A = 0 To UBound(KDasar)
-
e = InStr(1, pch(u), KDasar(A, 0), CompareMethod.Text)
-
If e > 0 Then
-
If KDasar(A, 1) = "3" Then
-
HslKet = Struktur(CInt(KDasar(A, 1)))
-
PosKt1 = u
-
ElseIf KDasar(A, 1) = "1" Then
-
HslPred = Struktur(CInt(KDasar(A, 1)))
-
PosKt = u
-
End If
-
End If
-
Next A
-
Next u
-
Next k
-
-
Lanjut:
-
If PosKt1 = 0 Then
-
PosKt = PosKt - 1
-
End If
-
-
HslObjek = Struktur(PosKt + 1)
-
HslSubj = Struktur(PosKt - 1)
-
If PosKt1 = 0 Then
-
HslString = HslKet & "-" & HslSubj & "-" & HslPred & "-" & HslObjek & "#" & Mid(hslImbuhan, 1, Len(hslImbuhan) - 1)
-
Else
-
HslString = HslSubj & "-" & HslPred & "-" & HslObjek & "-" & HslKet & "#" & Mid(hslImbuhan, 1, Len(hslImbuhan) - 1)
-
End If
-
StateMachine1 = HslString
-
End Function
-
-
Function BaseParsing(ByVal kt As String) As String
-
Dim A As Integer, e As Integer = 0
-
BaseParsing = kt
-
For A = 0 To UBound(KDasar)
-
e = InStr(1, kt, KDasar(A, 0), CompareMethod.Text)
-
If e > 0 Then
-
BaseParsing = KDasar(A, 0)
-
Exit For
-
End If
-
Next A
-
End Function
-
-
Sub StateMachine2()
-
Dim Wparts() As String = Split(txinput.Text, " ")
-
-
Dim state As Integer = 0
-
While True
-
' command = next command
-
Select Case (state)
-
Case 0
-
If (Command.Equals("USER")) Then
-
' username = argument;
-
state = 1
-
ElseIf (Command.Equals("QUIT")) Then
-
state = 4
-
Else
-
Error ("Unknown: " + Command())
-
' break()
-
End If
-
Case 1
-
If (Command.Equals("PASS")) Then
-
' If (valid(username, argument)) Then
-
' state = 2
-
' Else
-
' Error ("Unauthorized")
-
' state = 3
-
' End If
-
Else
-
Error ("Unknown: " + Command())
-
Exit While
-
End If
-
End Select
-
End While
-
End Sub
-
-
Public Class SingleObjClass
-
' private SingleObjClass obj = new SingleObjClass()
-
Private SingleObjClass()
-
' public SingleObjClass.getInstance()
-
' return obj;
-
End Class
-
-
Private Sub FrMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Call InisialisasiDB()
-
LS1A.Items.Clear()
-
LS1B.Items.Clear()
-
LS2.Items.Clear()
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim tmpRes As String = StateMachine1(LCase(txinput.Text))
-
Dim chnk1() As String = Split(tmpRes, "#")
-
Dim chnk2() As String = Split(chnk1(0), "-")
-
Dim chnk3() As String = Split(chnk1(1), "!"), j As Integer
-
-
Dim ptg() As String = Split(LCase(txinput.Text), " ")
-
-
LS1A.Items.Clear()
-
LS1B.Items.Clear()
-
LS2.Items.Clear()
-
-
For j = 0 To UBound(chnk2)
-
LS2.Items.Add(chnk2(j))
-
Next
-
-
For j = 0 To UBound(chnk3)
-
LS1B.Items.Add(chnk3(j))
-
Next
-
-
For j = 0 To UBound(ptg)
-
LS1A.Items.Add(BaseParsing(ptg(j)))
-
Next
-
-
End Sub
-
-
Private Sub LS2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LS2.SelectedIndexChanged
-
Dim j As Integer
-
For j = 0 To UBound(Struktur)
-
If LS2.Items(LS2.SelectedIndex) = Struktur(j) Then
-
LSDP.Text = DesStruktur(j)
-
Exit For
-
End If
-
Next j
-
End Sub
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
txinput.Text = ""
-
LS1A.Items.Clear()
-
LS1B.Items.Clear()
-
LS2.Items.Clear()
-
LSDP.Clear()
-
End Sub
-
End Class
please help me fix it..
thank you so much..
1 2267 Rabbit 12,516
Recognized Expert Moderator MVP
In your code, there exists the possibility that the index you're attempting to access goes outside the range of 0-3.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: smith flyers |
last post by:
string thingword=" testing hmmm";
string firstLetter,restOfWord;
foreach (string word in thingword.Split())
{
Console.WriteLine(word); // if this only use for output and the rest in
the block is commented, no error !!!
|
by: Pengyu |
last post by:
Whenever I call listView.RemoveAt(listView.Count-1),
which remove the last item, I get an out of range
exception. How to solve this problem?
Thanks a lot,
Pengyu.
|
by: Bill Johnson |
last post by:
I have a further question regarding an archive post at:
http://groups-beta.google.com/group/microsoft.public.dotnet.languages.csharp/messages/fe7604b410b324e8,ab8f23349b8bf19d,d79c7c14342df130,34af0447073a6842
and the error message:
System.ArgumentOutOfRangeException from System.Windows.Forms
Specified argument was out of the range of valid values.
Parameter name: '70' is not a valid value for 'displayIndex'.
|
by: Brad |
last post by:
Now I am encountering my second very strange problem. I will describe the first one later. But my current problem lies with trying to bind to a combobox:
Try
If clubID <> "" And txtYear.Text <> "" Then
DsEvents1.Clear()
daEventInfo.SelectCommand.Parameters(0).Value = clubID
daEventInfo.SelectCommand.Parameters(1).Value = txtYear.Text
daEventInfo.Fill(DsEvents1)
ElseIf txtYear.Text = "" Then
MsgBox("Event Year needs to be selected",...
|
by: Henry J. |
last post by:
Has anybody run into this index out range exception when opening and
then closing a collectionEditor from within a PropertyGrid?
I use PropertyGrid to edit configurations in my application. One of
the fields is a collection. I can expand or collapse the collection in
the PropertyGrid fine. However,if I open the CollectionEditor
associated with the collection, do nothing, and just close it, I get
an index out of range error. Note...
| |
by: Nick |
last post by:
Hi people,
I have a custom control combo box in a windows application that has a list
of items to be displayed. there are currently 17 items that are bound to the
table that acts as the data source for this combo. Now as this combo is an
editable box, when I try to add a new item, at times, and
ArgumentOutOfRangeException is raised. On debugging, this is raised whenevr I
try to access the control using:
Me.SelectedValue
or any other...
|
by: pcnerd |
last post by:
I'm trying to create a program that plots randomly colored pixels on a bitmap
& then displays the bitmap. When I run the program, I see the pixels being
plotted down the left side of the form. When it gets to the bottom, the
"Argument out of range exception" occurs. So, obviously the program starts.
The Help tells me that the argument isn't within the range of values, but it
doesn't explain how to fix the problem. So the Help doesn't help!...
|
by: dedipya |
last post by:
Environment W2003K with Oracle 10 client connected to oracle using oracle odp provider.orcle is on solaries machine.
while filling the dataset .net is throughing the error "argument was out of the range of valid values".
we are getting error when trying to fill the dataset with more than 16 columns.
if any date column is avaible in retrivels then fill dataset method is throwing the bellow error.
Parameter name: Year, Month, and Day...
|
by: Pucca |
last post by:
Hi: Below is the error I got from the 2 lines of code below. I don't
understand why and how to correct it. The actionMenu.DropDownItems has 0
item in its collection at the time of the code. Thanks.
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred
in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and
less than the size of the collection.
|
by: GR M |
last post by:
Hi,
I was trying to add two quantities at different rows of same description i.e same product_name and same item_pack.1st I want to check the table if it contains the same description or not by comparing with the first record and so on. When found, I'll add up the quantities and then to delete that particular row (to avoid duplicate search). But when I delete the row the particular row, next time it throws an out of index exception.
Below Is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |