|
Hi, can someone explain to me how I could make a program to be able to send voice over the internet (not VOIP, but something like msn messenger), or tell me where I could find this information?
|
|
|
|
|
Hi Folks!
This is my problem.
When I'm fetching data from a "box" via COMport it present the values that I need like this:
452F4AF6,
452E9548
439570B7
The 1. line is 2804 in decimal
The 2. line is 2793 in decimal
The 3. line is 298.9 in decimal.
In the manual this format is described as Ascii Hex IEEE Float.
If someone could't tell me how to convert from 452F4AF6 to 2804, 452E9548 to 2793 and so on, I would be very happy.
If you throw in a VB-Code as well, it would realy make my day
Have a nice day
RonnyK
|
|
|
|
|
The string is the hexadecimal representation of four bytes of data, but you have to find out if this is little-endinan or big-endinan format, and if it is four bytes, two words or one quadword, e.g. if it should be read as "45 2F 4A F6", "2F45 F64A" or "F64A2F45".
Either way you have to put those four bytes into a byte array in the correct order, and convert it to a Single. One way to do that would be to make a MemoryStream from the array, make a BinaryReader from the MemoryStream, and read the Single from the BinaryReader.
---
b { font-weight: normal; }
-- modified at 17:33 Monday 22nd May, 2006
|
|
|
|
|
Turns out I've already written code that does exactly this. I'm feeling like a nice guy today so I think I'll give you some of it.
(I don't normally do this.)
First you need to convert the ASCII string into integers. The below code will convert a portion of a string into an array of short ints.
''' <summary>
''' Extracts the ASCII characters out of string "sBuf" and returns them
''' as a zero based array of short integers. Each short holds 2 characters.
''' </summary>
''' <param name="sBuf"> The string to be converted to a short int array. </param>
''' <param name="iCharFirst"> Zero based index to 1st char to extract from "sBuf". </param>
''' <param name="iCharLast"> Zero based index to last char to extract from "sBuf". Must be >= iCharFirst. </param>
''' <returns> Returns short int array containing ASCII codes. </returns>
Public Shared Function StrToShorts(ByVal sBuf As String, ByVal iCharFirst As Integer, _
ByVal iCharLast As Integer) As Short()
Dim siArray() As Short
Dim iStrLen As Integer
Dim iIndex As Integer
Dim siValue As Short
' Validate arguments. (Okay if string is empty.)
If ((sBuf Is Nothing) OrElse (iCharFirst > iCharLast)) Then
' Invalid arguments. Return a NULLed array.
ReDim siArray(0)
siArray(0) = 0
Return siArray
End If
' Convert given string into an array of ASCII integer values.
iStrLen = sBuf.Length()
ReDim siArray((iCharLast - iCharFirst) \ 2)
For iIndex = 0 To (iCharLast - iCharFirst) Step 1
' Get next ASCII character in string.
If ((iIndex + iCharFirst) < iStrLen) Then
siValue = CType(Asc(sBuf.Chars(iIndex + iCharFirst)) And &HFF, Short)
Else
siValue = 0 ' Exceeded string length. Set NULL.
End If
' Push character's ASCII value into 2 byte integer array.
If ((iIndex Mod 2) = 0) Then
siArray(iIndex \ 2) = siValue << 8
Else
siArray(iIndex \ 2) = siArray(iIndex \ 2) Or siValue
End If
Next
Return siArray
End Function
You can combine 2 shorts into 1 Integer by using this code. This is also where you can swap words depending on endianess.
''' <summary> Combines two 2 byte integers into 1 long integer. </summary>
''' <param name="siHigh"> Will be the returned int's high word. </param>
''' <param name="siLow"> Will be the returned int's low word. </param>
''' <returns> Returns a 4 byte integer made up of siHigh and siLow. </returns>
Public Shared Function ShortsToInt(ByVal siHigh As Short, ByVal siLow As Short) As Integer
Dim bytesHigh() As Byte
Dim bytesLow() As Byte
' Get high bytes.
bytesHigh = System.BitConverter.GetBytes(siHigh)
If (bytesHigh Is Nothing) Then Return 0
If (bytesHigh.Length < 2) Then Return 0
' Get low bytes.
bytesLow = System.BitConverter.GetBytes(siLow)
If (bytesLow Is Nothing) Then Return 0
If (bytesLow.Length < 2) Then Return 0
' Combine to form a 4 byte integer.
Return System.BitConverter.ToInt32(New Byte() {bytesLow(0), bytesLow(1), _
bytesHigh(0), bytesHigh(1)}, 0)
End Function
Next, you'll need to convert that integer into a float. I recommend that you use the System.BitConverter class as shown below.
''' <summary>
''' Converts an integer into a float without changing bits.
''' </summary>
''' <param name="iValue"> Integer value to be converted to float. </param>
''' <returns> Returns a single precision float representation of given value. </returns>
Public Shared Function IntToFloat(ByVal iValue As Integer) As Single
Dim bytes() As Byte
'
bytes = System.BitConverter.GetBytes(iValue)
If (bytes Is Nothing) Then Return 0
Return System.BitConverter.ToSingle(bytes, 0)
End Function
|
|
|
|
|
Hi,
Can a timer tick event be started as a seperate thread and be executed concurrently with the KeyDown event?
When I press the Up arrow key, a picturebox1 has to go up and down the form vertically (jumping). At the same time, I would like the timer tick event to continue to move another picturebox2 from right to left on the form by 1 pixel for each tick event.
Initially, these 2 events cant be dealt with concurrently by vb, so I used the Application.DoEvent() method recommended by some replies I have received in the forums.
It works partially. Pictuerbox2 can move while the up arrow key is being pressed but it moves jerkily. Besides, when the arrow key is being released, picturebox1 continues to jump when it is supposed to stop.
So can I start a new thread which can execute when these 2 events occur?
If so, could you provide a simple example?
|
|
|
|
|
Yes, you can do that. However you will run into the problem of getting information across threads. To get around this, i'd recommend encapsulating both movements into their own class and run them on seperate threads. Within the class you would create delegates that would fire each time the key is pressed and each time the timer ticks. The delegate would then fire an event on your main form to update the appropriate picturebox.
I don't have VB available on this computer to write a quick example, but you can easily do a google on delegates to find out how to work those.
I know this doesn't give you the answer, but it gives you a path to start on If you still have troubles, let me know. I can write something up when I get home tonight.
|
|
|
|
|
hi
i'm trying to buld a project that asks the user to enter a number of nodes and then according to that number i need to build a a map with that number of nodes.
Any help would be appreciated
thank you in advance
|
|
|
|
|
Hi all,
I'm using Visual Basic 2005. I would like to loop through the controls
and wite or get some properties based on the controls.
This is the following piece of code in Visual Basic 6.0
For Each ctl In frm.Controls
Set ctl.Font = fnt
sCtlType = TypeName(ctl)
If sCtlType = "Label" Then
ctl.Caption = objLocalizer.GetResourceString(CInt(ctl.Tag))
ElseIf sCtlType = "CommandButton" Then
nVal = 0
nVal = Val(ctl.Tag)
If nVal > 0 Then
ctl.Caption = objLocalizer.GetResourceString(nVal)
End If
Debug.Print objLocalizer.GetResourceString(nVal)
nVal = 0
nVal = Val(ctl.ToolTipText)
If nVal > 0 Then
ctl.ToolTipText = objLocalizer.GetResourceString(nVal)
End If
ElseIf sCtlType = "Menu" Then
ctl.Caption = objLocalizer.GetResourceString(CInt(ctl.Caption))
ElseIf sCtlType = "TabStrip" Then
For Each obj In ctl.Tabs
obj.Caption = objLocalizer.GetResourceString(CInt(obj.Tag))
obj.ToolTipText = objLocalizer.GetResourceString(CInt(obj.ToolTipText))
Next
ElseIf sCtlType = "Toolbar" Then
For Each obj In ctl.Buttons
obj.ToolTipText = objLocalizer.GetResourceString(CInt(obj.ToolTipText))
Next
ElseIf sCtlType = "ListView" Then
For Each obj In ctl.ColumnHeaders
obj.Text = objLocalizer.GetResourceString(CInt(obj.Tag))
Next
ElseIf sCtlType = "ctList" Then
ctl.HeaderFont = fnt
Count = ctl.ColumnCount
For Index = 1 To Count
ctl.ColumnText(Index) = objLocalizer.GetResourceString(CInt(ctl.ColumnText(Index)))
Debug.Print ctl.ColumnText(Index)
Next Index
ElseIf sCtlType = "SSTab" Then
For Index = 0 To ctl.Tabs
ctl.TabCaption(Index) = objLocalizer.GetResourceString(CInt(ctl.TabCaption(Index)))
Next Index
ElseIf sCtlType = "ActiveBar" Then
Dim i As Integer
Dim J As Integer
Dim BandCount As Integer
Dim ToolsCount As Integer
BandCount = ctl.Bands.Count
For i = 0 To BandCount
ToolsCount = ctl.Bands(Index).Tools.Count
For J = 0 To ToolsCount
nVal = 0
nVal = Val(ctl.Bands(i).Tools(J).Tag)
If nVal > 0 Then
ctl.Bands(i).Tools(J).Caption = objLocalizer.GetResourceString(nVal)
End If
nVal = 0
nVal = Val(ctl.Bands(i).Tools(J).ToolTipText)
If nVal > 0 Then
ctl.Bands(i).Tools(J).ToolTipText = objLocalizer.GetResourceString(nVal)
End If
Next J
Next i
Else
nVal = 0
nVal = Val(ctl.Tag)
If nVal > 0 Then ctl.Caption = objLocalizer.GetResourceString(nVal)
nVal = 0
nVal = Val(ctl.ToolTipText)
If nVal > 0 Then ctl.ToolTipText = objLocalizer.GetResourceString(nVal)
End If
Next
When the same code is to be converted to Visual Basic 2005, i would
like to know how to access
1. ctl.HeaderFont in case of "ctList"
2. ctl.ColumnCount in case of "ctList"
3. ctl.ColumnText(Index) in case of "ctList"
4. ctl.Tabs in case of ctl is a SSTab
5. ctl.TabCaption(Index) in case of a Tab in SSTab
Any Help in this regard would be appreciated
Thanks in advance,
Sugan
Chennai
|
|
|
|
|
How do you loop through controls in a form
<br />
For Each ct As Control In Me.Controls<br />
MessageBox.Show(ct.GetType.ToString) <br />
Next
I suppose ctList and the SSTab are third party tools. so you need to create an object of ctList and SSTab to access their properties. Common properties of a control like background, name, etc can be accessed in above mentioned way. Properties like HeaderFont, ColoumnCount are specific to that Control.
So You need to create that particular object to access their properties. Here is an example, this is for the textbox and this should be same for SSTab and CtList, i guess.
For Each ct As Control In Me.Controls<br />
MessageBox.Show(ct.GetType.ToString)<br />
ct.BackColor = Color.AntiqueWhite<br />
If ct.GetType.Name.Equals("TextBox") Then<br />
Dim tb As TextBox 'here you can use SSTab or whatever <br />
tb = ct<br />
tb.BackColor = Color.Blue<br />
End If<br />
Next
|
|
|
|
|
I'm writing a program which similar outlook expess. I wish create a formatting toolbar at form "new mail". I can create it with combo box, toolbox but I think there are other ways create it. Please help me. Thank
|
|
|
|
|
Hi , i know this is stupide but can you tell me what is assembly ?? & when can we use it ?? & why ??
thnx
try to be good if you can't be the best
|
|
|
|
|
|
thnx man this really very very interesting course it is more than enough but i think without practicing it i won't understand anything of it so please if you can send me real codes of assemliese & better if you can make explanation of each statement or instrection in or else give me a vedio if you have one that explain what is that sh*t
but anyway i want to thank you very very much
if you see that what i told you abt bringing informations is really herd or diffecult you can kick that sh*t away & i will try maself
thank you
try to be good if you can't be the best
|
|
|
|
|
Hi ,
please i want to know how can i fill the list box in form1 from the list box in form2
i will give the example to make it clear :
i have a listbox in form1 & i have an other one in form two
in form1 i have a botton & also in form2
well, when i click on button in form1, form2 is shown & i do somethings in & now i have a filled listbox in form2 i want when i click on the button in form2 the listbox in form1 get filled with items i have in listbox of form2
i hope you got it cuz ma english is really stupide just do your effort to understand because this is one of the last two problems i have now to finish my application
thank you very much
try to be good if you can't be the best
|
|
|
|
|
You should create a member variable in Form2 to store all items in its ListBox. You should add items to this member variable when you click Form2's button (an OK button?). Then create a public function in Form2 that'll return this collection of items.
Public Class Form2 : Inherits Form
Private selectedItems() As Object
'
Private Sub okButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles okButton.Click
' Copy selected items to array member variable.
' This array is returned on GetSelectedItems().
ReDim selectedItems(myListBox.Items.Count - 1)
myListBox.Items.CopyTo(selectedItems, 0)
End Sub
'
Public Function GetSelectedItems() As Object()
Return selectedItems
End Function
End Class
In Form1, you would display Form2 and fetch its ListBox items like this.
Dim myForm As New Form2
Dim selectedItems() As Object
myForm.ShowDialog()
selectedItems = myForm.GetSelectedItems()
|
|
|
|
|
Hi to all,
can anyone give me a head start on following problem:
I have an applications in which I add controls to a treeview (treeview = container). The problem is that when i scroll my treeview, the nodes move but the controls stay at their place ( the don't move in other words). ANy idea on how to make them move and keep their raltive position (now they are located next to the node which handles as the controls label)
kind regards,
Bats (Mike Martin)
|
|
|
|
|
i have used check constarin like this
constraint disignation CHECK(Designation IN('Key Person','Assignee')),
when i try to enter data using my code
it,s getting error on this constrain.
in the code i have used combo box and there fixed items.i access this item using "bombobox1.selecteditem"
but i check it using msgbox and it,s giving correct word.i,m confused with this coz i have used this on vb.net 2003
now i,m using vs2005
can any one help me
my quary string is like this
"insert into Complaint values('" & cbocustomerId.SelectedItem() & "','" & cborepID.SelectedItem() & "','" & cbosource.SelectedItem() & "','" & rtxtdescription.Text & "','" & cboempID.SelectedItem() & "','" & txtdate.Text & "','" & cbocatagory.SelectedItem() & "','" & cboFtype.SelectedItem() & "' ,'" & txtvehicleNo.Text & "','" & txtbustop.Text & "','" & cboOp_dept_no.SelectedItem() & "','" & cbostatus.SelectedItem() & "','" & txtrefNo.Text & "','" & txtplace.Text & "')")
-- modified at 7:39 Monday 22nd May, 2006
|
|
|
|
|
I have make a application that the user will open a whole day,
The application contains a folder watcher, when new file created in that folder,
A event will rise.
How can I set my application at the top of screen?
I have tried me.show, me.activate, me.WindowState = FormWindowState.Maximized ...
All these cannot work properly.
|
|
|
|
|
Hi,
If you are trying to make the window as top-most accessible window you should try to load it with .ShowDialog instead of show.
batmike2000
|
|
|
|
|
Hi ,
Can anyone tell me the code (in vb.net) to delete one record from the database. I m totaly confused about it. Plz tell.
Thanks.
Swati Pathania.
|
|
|
|
|
Hi,
Do you want sql query for that.
Best Regards,
Apurva Kaushal
|
|
|
|
|
no sql query
you have to use the dataset & the table in the dataset you have that record in
& you have two ways
if you are working with rownb
well i can't explain now but it is pretty easy give me just how you fill fields from database i meant the methode or the way you follow to reward your records & i will write you how to delete it with all the necessary explanation , are you happy ?? don't be confused nobody was born knowing everything
try to be good if you can't be the best
|
|
|
|
|
Mohammed Amine wrote: no sql query
you have to use the dataset & the table in the dataset you have that record in
If you are using a dataset, what do you think the .NET Framework sends to the database? A SQL Query. So there is a SQL Query.
The OP also did not say anything about using DataSets so this solution may not be advisable in his situation.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
yeah right , but how can he show filled fields without using dataset ??
i think if he want to update on database he is obliged to use it
so i asked him for the way he use to forward or to show his records in the fields that is all
sorry i didn't want to mean no sql query just i wanted to make it easy for him
try to be good if you can't be the best
|
|
|
|
|
Mohammed Amine wrote: yeah right , but how can he show filled fields without using dataset ??
There are many ways to show data without a data set. In general I rarely use them.
Mohammed Amine wrote: i think if he want to update on database he is obliged to use it
There is no obligation to use a dataset to update a database. The dataset is often a cumbersome representation of a database inside an application that can be more efficiently replaced. I only use datasets in throw away applications that I don't intent to maintain because they come with so many constraints.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|