|
you need to 'Load' the new control.
Example:
Load grpButtons(iBtn)
With grpButtons(iBtn)
.value = False
.Left = grpButtons(0).Left
.Top = grpButtons(iBtn - 1).Top + .Height
.Caption = frm.sFormName
.Visible = True
End With
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: Load grpButtons(iBtn)
I tried this too but still I have this absurd exception!
Runtime error '91'
Object variable or With block variable not set!!!!
|
|
|
|
|
Sorry for not looking closer...
You cannot do what your code says you want to do in vb6.
First of all the creation of controls at runtime -- it's based on an already existing control that has the index property set to 0. You can only create additional instances using the 'load' command. You cannot create any control on the fly unless there is already one present on the screen.
If you look at the click event of the label you'll notice that a new argument is in the signature of the routine.
Private Sub Label1_Click(Index As Integer)
this allows you to create a new intance at run time because every label when clicked on will come into this routine and then you can test what value is the index, etc. because you cannot assign an event handler at runtime like you can in dotnet, you have no choice...
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
I haven't used VB6 in a VERY long time. Look at all the things that I've (thankfully) forgotten!
|
|
|
|
|
your lucky... I'm still blessed to work with it occassionally...
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Ah, yes...
I vaguely remember reading something like this...
|
|
|
|
|
At last!
I found the solution!
I added an indexed label in my form, changed its Index to 1 and copy 10 labels from that, like this:
For t% = 2 To 10
Load lblPage(t%)
lblPage(t%).Top = (t% \ 100) * lblPage(1).Height
lblPage(t%).Left = (t% Mod 100 - 1) * lblPage(1).Width
lblPage(t%).Visible = True
Next t%
Thank you all
|
|
|
|
|
Hi all,
i'm trying to save an image in database ina binary format,
Image:Is my table name
Pic is my column name
these are my functions:
<WebMethod()> _
Public Function ImageToByte(ByVal filepath As String) As Byte()
Dim fs As FileStream = New FileStream(filepath, FileMode.Open, FileAccess.Read)
Dim BR As BinaryReader = New BinaryReader(fs)
Dim photo As Byte() = BR.ReadBytes(fs.Length)
BR.Close()
fs.Close()
Return photo
End Function
<WebMethod()> _
Public Sub saveimage(ByVal imagebyte As Byte())
Dim cnn As New SqlConnection("myconnectionstring")
Dim cmd As New SqlCommand()
Dim da As New SqlDataAdapter()
Dim cbuilder As New SqlCommandBuilder(da)
Dim ds As New DataSet()
Dim cmdStr As String
cmdStr = "SELECT * FROM Image"
If cnn.State = ConnectionState.Open Then
cnn.Close()
End If
cnn.Open()
cmd.Connection = cnn
cmd.CommandText = cmdStr
da.SelectCommand = cmd
da.Fill(ds, "Image")
Dim nrow As DataRow
nrow = ds.Tables("Image").NewRow()
nrow.Item("Pic") = imagebyte
ds.Tables("Image").Rows.Add(nrow)
da.InsertCommand = cbuilder.GetInsertCommand
da.Update(ds.Tables("Image"))
cnn.Close()
End Sub
and this is my code for using this functions:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ws As New localhost.Service()
Dim a As Byte()
a = ws.ImageToByte(TextBox1.Text)
ws.saveimage(a)
But when i click on Button1 this Error occured:
SQLException was unhandled by user code
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: String or binary data would be truncated.
why this error occured?
please help me,
Thank You
Hoda
|
|
|
|
|
Saba02 wrote: System.Data.SqlClient.SqlException: String or binary data would be truncated.
Your column don't have enough capacity to hold the binary data. Try incresing the column's allowed space.
|
|
|
|
|
It's been a few days and I have not been able to figure out my mistake. I have 2 combo boxes I want the two combo1 as the parent and combo2 to be the child.
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
Dim strProvider As String = "Microsoft.Jet.OLEDB.4.0"
Dim strConnect As String
Dim cnn As OleDbConnection
Dim cmd As OleDbCommand
Dim odr As OleDbDataReader
Dim da1 As OleDbDataAdapter
Dim da2 As OleDbDataAdapter
' Connect to unsecured Access database
strConnect = String.Format("Provider={0};Data Source={1};", strProvider, txtPath.Text)
'Initialize the DataSet object
Dim ds As New DataSet()
'Create Command object
Dim cmd1 As String = "SELECT * FROM ER"
Dim cmd2 As String = "SELECT * FROM Thickness"
Try
' Retrieve and open a connection.
cnn = New OleDbConnection(strConnect)
cnn.Open()
'Initialize the DataAdapter object and set the SelectCommand property
da1 = New OleDbDataAdapter(cmd1, cnn)
da2 = New OleDbDataAdapter(cmd2, cnn)
'Populate the DataSet
da1.Fill(ds, "ER")
da2.Fill(ds, "Thickness")
' Define the relationship between the tables.
ds.Relations.Add(New DataRelation( _
relationName:="relERThickness", _
parentColumn:=ds.Tables("ER").Columns("ER_ID"), _
childColumn:=ds.Tables("Thickness").Columns("ER_ID"), _
createConstraints:=False))
'Bind the DataTable to the ComboBox
ComboBox1.DataSource = ds
ComboBox1.DisplayMember = "ER"
'Bind the DataTable to the ComboBox
ComboBox2.DataSource = ds
ComboBox2.DisplayMember = "ER.relERThickness"
Catch exp As Exception
MsgBox(exp.Message)
Finally
If Not odr Is Nothing Then
odr.Close()
End If
If Not cmd Is Nothing Then
da1.Dispose()
da2.Dispose()
End If
If Not cnn Is Nothing Then
cnn.Dispose()
End If
End Try
End Sub
|
|
|
|
|
Begin PART 1 :
I have a sub
Private Sub PrintProperties(Of T)(ByVal pItem As T)
[...]
End Sub that I need to access it through MethodInfo :
Private Sub PrintPropertiesMaster(Of T)()
[...]
Dim method As MethodInfo = GetType(Form1).GetMethod("PrintProperties", _
(System.Reflection.BindingFlags.Instance _
Or (System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.NonPublic)), _
Nothing, New Type() {GetType(T)}, Nothing)
[...]
End Sub but method is set to nothing after the previous line.
I'm sure I miss something in the Type.GetMethod parameters. Any idea?
End PART 1
Begin PART 2 :
Another way to achieve my goal could be to know how to specify a TypeParam dynamically.
Let me explain this with sample :
This is my not conforming code:
For Each oEnt As Entity In DefaultManager.GetEntities(Of SomeNameSpace.ObjOne)()
PrintProperties(Of SomeNameSpace.ObjOneDataRow)(CType(oEnt, SomeNameSpace.ObjOneDataRow))
Next
For Each oEnt As Entity In DefaultManager.GetEntities(Of SomeNameSpace.ObjTwo)()
PrintProperties(Of SomeNameSpace.ObjTwoDataRow)(CType(oEnt, SomeNameSpace.ObjTwoDataRow))
Next
'And so on
[...] I need to access it using a System.Type instead of TypeParam (Of Something )
(Consider that ObjOne Inherits from ObjOneDataRow and ObjTwo Inherits from ObjTwoDataRow.
In other words, ObjOneDataRow is the base class of ObjOne)
So one parameter should be enough to know all the needed System.Type to finish with something like this :
Private Sub PrintValues(Of T)()
For Each oEnt As Entity In DefaultManager.GetEntities(Of T)()
PrintProperties(Of GetType(T).BaseType)(CType(oEnt, GetType(T).BaseType))
Next
End Sub but this does not compile
End PART 2
Thanks for any help!!!
|
|
|
|
|
I get the error: "Invalid Parameter Used" when i try to display an image
I believe this occurs at DisplaySignPictureBox.Image = Image.FromStream(mem)
Try
Connect()
jesacmd = New SqlCommand("SELECT PER_SIGN FROM PER_INFO_SIGN WHERE PER_NAME
= '" & CheqOwnerComboBox.SelectedItem.ToString & "'", jesacon)
Dim da As New SqlDataAdapter(jesacmd)
Dim ds As New DataSet
da.Fill(ds, "PER_INFO_SIGN")
Dim c As Integer = ds.Tables("PER_INFO_SIGN").Rows.Count
If c > 0 Then
Dim jbyte() As Byte = ds.Tables("PER_INFO_SIGN").Rows(c - 1)("PER_SIGN")
Dim mem As New MemoryStream(jbyte)
DisplaySignPictureBox.Image = Image.FromStream(mem)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
jesacon.Close()
modified on Tuesday, September 23, 2008 9:58 AM
|
|
|
|
|
In VB6 i want to display the dollar,pund and euro depending on the countries.I am using "SetLocaleInfo" function .I am having the error like "function not defined" .Please tell me how to define this function.thanks in advance
----------------------------------------------------------
Dim IntLocale As Integer
IntLocale = SetLocaleInfo(2057, 1, "H")
If (CurrCntryCode = "EP") Then
xlApp.ActiveSheet.Range("J" & NxtLine).NumberFormat = "€#,##0.00"
Else
If (CurrCntryCode = "HK") Then
xlApp.ActiveSheet.Range("J" & NxtLine).NumberFormat = "$#,##0.00"
Else
If (CurrCntryCode = "UK") Then
xlApp.ActiveSheet.Range("J" & NxtLine).NumberFormat = "£#,##0.00"
Else
xlApp.ActiveSheet.Range("J" & NxtLine).NumberFormat = "£#,##0.00"
GridFormatCellFunction("J" & NxtLine) = "Format,£#,##0.00"
End If
End If
End If
|
|
|
|
|
You're getting the message "function not defined" because you haven't defined SetLocaleInfo anywhere in your code.
|
|
|
|
|
Hi friends,
Can anyone tell me how to print current document using VB.net 2005.
Also tell me how can I format a report..
Thanks...
|
|
|
|
|
Hi, I need to convert Topographic Map/ Contour Map into another view like the image shown below in VB.net. The value of each contour line will be input by user which will be the value of Y. What I need is the way to extract the point which will be the value of X.
Sorry that I do not know how to describe the view I want to convert to.
Can anyone give me idea how to get it done?
|
|
|
|
|
Hi guys, i need help on my symbol mc1000 barcode scanner.
I would like to create an ascii file and store the scanned barcode (decoded) in that ascii file, together with the system date as i scan a barcode. the ascii file will then be downloaded to a pc for further processing.
Any help would be very much appreciated. Thanks.
|
|
|
|
|
jayv01 wrote: i need help on my symbol mc1000 barcode scanner.
I would like to create an ascii file and store the scanned barcode (decoded) in that ascii file, together with the system date as i scan a barcode. the ascii file will then be downloaded to a pc for further processing.
Write a form that will accept a text input and scan the bar code. You should now have the scanned data in the text box - write it out with the system date to file, and clear text box.
A bar code scanner is usually a keyboard wedge - it imitates a keyboard.
HTH
|
|
|
|
|
Hi ChandraRam,
Thanks for your reply. But the barcode scanner that i am using is not a keyboard wedge but a standalone barcode scanner. Basically, the scanning of barcodes will be done by batch and will just save the data in the scanner (Symbol MC1000). Once done, I will download the ascii file from the barcode scanner to the user computer for more processing.
Sandz
|
|
|
|
|
Hi All!
I need to have drag events on a webbrowser control that it does not currently provide, I've googled this, but can't seem to find a clear answer. Does anybody have any ideas on this?
Thanks!
MrWolfy
|
|
|
|
|
|
Hi and Thanks!
Thanks for the link! Problem Solved!
Thanks Again!
MrWolfy
|
|
|
|
|
|
hai all,
i am new to vb.i am using visual basic 6.0.
back end is microsoft access.
i want to get the datas from microsoft access database and list that datas in combobox or listbox.how to do this?...thanks in advance to all...
|
|
|
|
|
Where to begin?
- You need to buy a book on programming.
- You need to move to VB.NET, vb6 has been dead for several years
- You need to write some code and post it here when it doesn't work
Bob
Ashfield Consultants Ltd
|
|
|
|