vb6 textbox show false message sdafjklasdf - vb6

textbox show "false" when I click datalist .
please help me .
stuck here .
Private Sub DataList1_Click()
Txtnama.Text = DataList1.ListField = "nama"
End Sub
please help me guys .

You can't cascade an assignment statement. Your statement is performing a comparison: Datalist1.ListField = "nama", then assigning the results of that comparison (True or False) to the textbox.
Perhaps you want to be assigning the same value to the textbox and list field? If so, then you should use this:
txtnama.Text = "nama"
DataList1.ListField = "nama"
If that's not what you are trying to do, then you need to provide a better, more complete explanation of your requirements.

Related

Retrieving Only Selected Field Using LINQ

i have a problems regarding on filtering my code in retrieving companyName from its table..when i query here is the result .. please see my code
Sub call_customers(ByVal dgv_customers As DataGridView)
Dim customers_name = From cust In dbcon.Customers _
Select cust.CustomerID, cust.CompanyName Order By CompanyName Ascending
dgv_customers.DataSource = customers_name
End Sub
the display is CustomerID and CompanyName.. yeah its true.. no problem with the code..
and if i only select cust.companyname the result is this ....like this code
Sub call_customers(ByVal dgv_customers As DataGridView)
Dim customers_name = From cust In dbcon.Customers _
Select cust.CompanyName
dgv_customers.DataSource = customers_name
End Sub
the output is this...
enter image description here
no display and it says length.. why? newbie in LINQ sir ..
please help..
Originally, you were giving the grid an object, and it was displaying each of the properties of that object.
Now that you are giving it a string, it is doing the same thing, but now, the only property on the string is the length,

Incorrect data showing in VB6 textbox

I am setting a datalist which looks like this:
And I have table like this:
+-------------------+
|---ID----|---NAME--|
+-------------------+
|---101---|---CNN---|
|---102---|---BBM---|
+-------------------+
On the datalist I am using ID for listfield. I want show the name directly in the textbox when I choose ID list from listfield.
e.g. : i choose ID 101 in datalist then show "CNN" in textboxname
Private Sub DataList1_Click()
Txtnama.Text = DataList1.ListField = "nama"
End Sub
Problem: the textbox just shows "false".
How do I fix this code.
please help me
thanks
The problem is in the line:
Txtnama.Text = DataList1.ListField = "nama"
The right hand side of this assignment is the expression
DataList1.ListField = "nama"
which is a boolean expression. So the value of the .Text property is set to that boolean value.
Probably what you actually want to do is this:
Txtnama.Text = DataList1.ListField("nama")
so that you select only the nama value from the DataList object.

How to translate a part using CATscript in CATIA?

I working with CATscript in CATIA to create Macros. I am trying to create a CATscript to translate a feature in CATIA.
When I run the CATscript I Should select the feature that should be translated and and the feature will be translated.
But I am getting an runtime error Type mismatch:'part1.CreateReferenceFromObject'
I could not find the solution for this problem.
Looking forward for your help.
Thanks in Advance.
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(1.000000, 0.000000, 0.000000)
Set hybridShapeTranslate1 = hybridShapeFactory1.AddNewEmptyTranslate()
Set UserSel = partDocument1.Selection
Dim type1(0)
type1(0) = "HybridShape"
'--------------------------------------
'Dim input As Object
input = UserSel.SelectElement2(type1, "select input.", False)
Set reference1 = part1.CreateReferenceFromObject(input)
hybridShapeTranslate1.ElemToTranslate = reference1
hybridShapeTranslate1.Direction = hybridShapeDirection1
hybridShapeTranslate1.DistanceValue = 1.000000
Set hybridBody2 = hybridBodies1.Item("Geometrical Set.3")
hybridBody2.AppendHybridShape hybridShapeTranslate1
part1.InWorkObject = hybridShapeTranslate1
part1.Update
End Sub
your problem is that you are trying to create a reference from a Selection object.
input = UserSel.SelectElement2(type1, "select input.", False)
This returns the type Selection. You can dig into the input and get the actual object that you select.
try:
Dim myReference as Reference
Dim myExpectedObject as HybridShape 'or use variant
Set mySelectedObject = input.Item2(1).Value 'this will grab the first item from the selection collection
set myReference = part1.CreateReferenceFromObject(mySelectedObject)
'continue the rest of your code
Also, you should always clear the selection before you use a user selection as a good habit.
UserSel.Clear 'call this before you call a SelectElement selection function

customunboundcolumndata event not firing in DEVExpress gridview

I have been struggling with the below code snippet. "CustomUnboundColumnData" event is not firing.
Protected Sub gvAlertReport_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs)
If e.Column.FieldName = "Active" Then
Dim val As String = e.Value
Dim img As New ImageButton()
Select Case val
Case "False"
img.ImageUrl = "Images/gray_bell.png"
img.Attributes.Add("", "")
Case "True"
img.ImageUrl = "Images/red_bell.png"
img.Attributes.Add("", "")
Case Else
End Select
End If
End Sub
Thanks in Advance..
The CustomUnboundColumnData event is only triggered if there is a column in the ASPxGridView which is designed as an Unbound Column. To learn how this can be done, please refer to the Unbound Columns Overview topic. Also, please make certain that the gvAlertReport_CustomUnboundColumnData is the actual event handler for the ASPxGridView.

VB6.0 with DataControl Database Programming

Hey, can I ask you something? I'm using VB6.0 and I have some problem with the connection of my Database through DataControl. I have a table named tblEmployee and the other one is tblPosition then I passed the value of the two tables to two DataControls respectively. How can I then get the value of a certain row of Position field. With my code, my Position field returns only the first row. Here's my code
Private Sub cmdSearchEmployee_Click()
With datEmployee.Recordset
datEmployee.Recordset.Index = "idxid"
datEmployee.Recordset.Seek "=", txtIDNumber.Text
If .NoMatch = True Then
MsgBox ("No Record Found!")
Else
Me.txtLastName.Text = .Fields("lname")
Me.txtFirstName.Text = .Fields("fname")
Me.txtMiddleName.Text = .Fields("mi")
With datPosition.Recordset
Me.txtPosition.Text = .Fields("position")
End With
End If
End With
End Sub
I can't see that you have "passed the value" to your DataControl named datPosition. Could this be the problem? e.g. where you have
With datPosition.Recordset
Me.txtPosition.Text = .Fields("position")
End With
...should be more like this:
With datPosition.Recordset
.Index = "some_index??"
.Seek "=", "some_value??"
Me.txtPosition.Text = .Fields("position")
End With
Also consider using the recordsets' Filter to remove the rows that do not match your criteria then RecordCount to loop through the rows that do match your criteria.
Further consider returning a single recordset by creating a join between tblEmployee and tblPosition, either in SQL code or returning a hierarchical recordset using the MsDataShape with its SHAPE syntax.

Resources