|
Hi,
a property that gets several values assigned to it only remembers the last value, so having Me.txtpov.Text = something in a loop like that does not make sense. Either use a Control that knows how to collect multiple items, or concatenate all strings you want to be shown.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Dim i, t As Integer
t = Me.chklistbox.CheckedItems.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + ","
Next
* You were counting all the items in your loop, whilst you only want to iterate through the checked ones.
* You were overwriting your textbox with the text of the last two items found, whilst you want to append text to the textbox, for each checked item.
Enjoy
I are troll
|
|
|
|
|
hi
the code u suggested works thank you very much...
but problem is that all the items are added to multiline textbox after i click save button..
for eg:-
if i tick on item 'a' of checklistbox and then click on save button that item appears in multiline textbox now suppose i again tick on item 'b' in checklistbox and than click save button at this item 'a' is again added to multiline text box so the outcome is 'a','a','b' which means repetation of 1st item this happens every time i click on save button...
my code is:-
Private Sub btnsave2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave2.Click
Try
If Me.chklistbox.SelectedIndex = -1 Then
MsgBox("nothing selected")
Exit Sub
End If
Dim i, t As Integer
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + ","
Next
Catch ex As Exception
ex.ToString()
End Try
End Sub
please suggest what shall i do to clear multiline textbox before saving it...
|
|
|
|
|
Try
If Me.chklistbox.SelectedIndex = -1 Then
MsgBox("nothing selected")
Exit Sub
End If
Dim i, t As Integer
Me.txtpov.Text.Clear()
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + ","
Next
Catch ex As Exception
ex.ToString()
End Try
I are troll
|
|
|
|
|
hi
thanks for your suggestion the code you gave is working..
but the content is displayed in single line
can u please suggest what shall i do to display it in next line..
i mean after ','i want it to be displayed in next line...
i m beginner so please help....
|
|
|
|
|
Try
If Me.chklistbox.SelectedIndex = -1 Then
MsgBox("nothing selected")
Exit Sub
End If
Dim i, t As Integer
Me.txtpov.Text.Clear()
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + Environment.NewLine
Next
Catch ex As Exception
MessageBox(ex.ToString())
End Try
I are troll
|
|
|
|
|
|
u concenate to character where is find , or '' and than match to database if find than no update this else update data base
but i can't understand which type of application u devloped
warm regard
dinesh rajut
global infotec
India
dinua1091@rediffmail.com
|
|
|
|
|
Hi,
How can I use { in my string.Format?(it's part of my string) and & _ for contacting string. In below code it says 'Input string is not in correct Format':
<br />
String.Format("function (s,e){if(e.item.name == 'OtherField'){if(" & _<br />
"'{0}'.IsCustomizationWindowVisible() == false){" & _<br />
"'{0}'.ShowCustomizationWindow()} else{" & _<br />
"'{0}'.HideCustomizationWindow()}" & "}else if(e.item.name == 'Group'){" & _<br />
"if(e.item.GetChecked()){'{0}'.PerformCallback()}}}", Me.ClientInstanceName)<br />
Best wishes
|
|
|
|
|
Search on 'Escaping Braces'.
That should give you the start you require.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Experts,
I have a SAP RFC (Remote Function Call) which is being called from VB6 code. Being a ABAPer I dont have knowledge of VB programming. I would be thankful if someone give me code for passing table name to SAP RFC.
********My RFC is as given below
CALL FUNCTION 'ZTEST_RFC'
TABLES
IT_RFCTABLE = VB_TABLE_NAME????
EXCEPTIONS
NOT FOUND = 1
INSERT_FAILURE = 2
OTHERS = 3.
I need to pass a table from my VB6 code and my data is stored in SQL2000.
Even the code from .NET will be welcome.
Thanks in advance.
modified on Saturday, March 28, 2009 1:44 PM
|
|
|
|
|
Without seeing the code you have now, I can olnyl make assumptions (bad idea!) about what you're after. Something like this maybe:
Dim queryString as String
queryString = "CALL FUNCTION 'ZTEST_RFC' TABLES " & _
"IT_RFCTABLE = " & tableName & " EXCEPTIONS " & _
"NOT FOUND = 1 INSERT_FAILURE = 2 OTHERS = 3."
I have no idea if this string is going to work becuase I've never written code for SAP RFC.
|
|
|
|
|
Hi,
I am tryign to play a MP3 file via mcisendtring. However, it doesn't play anything. I couldn't figure out what is causing it. It doesn't give me any error message and it doesn't play it also. If you know the problem, would you please let me know.
Thank you.
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Player
Private isOpen As Boolean = False
Private GetFileName As String = Nothing
'mciSendString
<[DllImport]("winmm.dll")> _
Private Shared Function mciSendString(ByVal command As String, ByVal ReturnValue As StringBuilder, _
ByVal returnLength As Integer, ByVal winHandle As IntPtr) As Long
End Function
'This procedure closes the playing media file
Public Sub ClosePlayer()
If (isOpen) Then
Dim PlayCommand As String = "Close " + GetFileName
mciSendString(PlayCommand, Nothing, 0, IntPtr.Zero)
isOpen = False
End If
End Sub
'This procedure will open the media file
Private Sub OpenMediaFile()
ClosePlayer()
Dim PlayCommand As String = "open \""" + GetFileName + " \ "" type mpegvideo alias MediaFile"
mciSendString(PlayCommand, Nothing, 0, IntPtr.Zero)
isOpen = True
End Sub
'This sub procedure will play the media file
'
Private Sub PlayMediaFile()
If (isOpen) Then
Dim PlayCommand As String = "play " + GetFileName
mciSendString(PlayCommand, Nothing, 0, 0)
End If
End Sub
'This sub procedure will initiate playing
Public Sub Play(ByVal FileName As String)
GetFileName = fileName
OpenMediaFile()
PlayMediaFile()
End Sub
'this procedure will pause the file
'
Public Sub Pause()
mciSendString("pause " + GetFileName, Nothing, 0, IntPtr.Zero)
End Sub
'This sub procedure will resume the file
'
Public Sub Resumit()
mciSendString("resume " + GetFileName, Nothing, 0, 0)
End Sub
End Class
Dim playclass as new Player
playclass.play("hello.mp3")
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hi,
The original c# code in the CP article http://www.codeproject.com/KB/audio-video/a_mini_media_player.aspx[^]was this:
private void OpenMediaFile()
{
ClosePlayer();
string playCommand = "Open \"" + fileName +
"\" type mpegvideo alias " + mediaName;
mciSendString(playCommand, null, 0, IntPtr.Zero);
isOpen = true;
}
I haven't programmed in Basic since QuickBasic, which dates me a bit, but I don't think you have translated the formatting of the playCommand string correctly.
The c# code produces, from a fileName of c:\music.mp3 and mediaName of media, the string
Open "c:\music.mp3" type mpegvideo alias media
Alan.
|
|
|
|
|
Thanks for responding. I think it was your code where I took it to test. I corrected the code after your post but it is still not working. Somehow it is not talking to winmm.dll.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hi,
Are you able to compile the original c# source. I've just done that and the app will play mp3 and wav files perfectly on my system. If you were able to do the same at least you would know whether your computer or your translation is the cause of the problem.
Alan.
|
|
|
|
|
I beleive that your code is perfectly running in C#. The problem is it is not communicating winmm.dll I made a mistake somewhere and I will eventually find it. Do you know any more developed class file somewhere where I can download it?
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hi,
I haven't come across anything like that.
Alan
|
|
|
|
|
Just tested the VB.NET code. As Alan states, there's a translation error from C# to VB.NET here:
'This procedure will open the media file
Private Sub OpenMediaFile()
ClosePlayer()
Dim PlayCommand As String = "open """ + GetFileName + """ type mpegvideo alias MediaFile"
mciSendString(PlayCommand, Nothing, 0, IntPtr.Zero)
isOpen = True
End Sub
Enjoy
I are troll
|
|
|
|
|
Hi. First off I apologize if I'm posting this in the wrong forum, this is my first time posting here. I'm working on a project and a segment of the project deals with random stat (stat as in rpg stats) generator and I've encountered a bit of a problem. The program, which we'll call Character Creator for now, offers the user three ways to generate six stats. Rather than posting all of the code (which is about 750 pertinent lines) I'll describe how the first method works. This method is the equivalent of adding the result of four six-sided dice, re-rolling on ones, and dropping the lowest number.
Here is a screen shot of the design view of my program[^]
This image shows how the check boxes allow the user to assign a single stat to each number[^]
Because of how time consuming it took to make just one generator on the form, I made it into a user control so I could simply drag and drop it onto the form three times, thus giving the user the ability to select from one of three different sets of numbers to work with. This is where the problem comes in. My problem is that I don't know how to access the text boxes or check boxes in the control or is such a thing is possible. For example, this what I first tried to see if I could still access components and variables of the control:
'genOne is the name of the first generator
'txtStatOne is the name for the first text box in the column
'statOne is the name of the random variable
genOne.txtStatOne.text = statOne
I need to do this because after the set of numbers is selected and assigned to a stat, it will be sent to be stored in a database along with other pieces of information. This part has yet to be implemented so on the form there will be a "Finish" button that sends all entered information to a database. Any help is much appreciated.
|
|
|
|
|
First, I think the UI you've come up with is confusing, but hey, it's your app.
Next, you had the right idea putting this in a User Control. The problem is you have to write some code in the User Control to expose the data in the text boxes and checkbox's in a manner that would make sense to an outside consumer, like your main form, using public properties and/or events. You do NOT expose the constituent controls outside of the User Control.
|
|
|
|
|
Ah, thanks much for pointing me in the right direction. I've messed around a bit with the code and it looks like everything is working fine.
However I've got one more question. You said the UI was confusing. How so? As this projects wears on I hope to have a list of questions and such about the program or possible revisions.
|
|
|
|
|
XaviousWolffe wrote: You said the UI was confusing. How so?
How you noticed all the checkbox's you've splattered all over the screen?? Wouldn't be better to setup a drag'n'drop solution to move the values to the appropriate attributes??
|
|
|
|
|
How can I write a shell extension with Visual Basic 2005 / 2008 Express? Any help would be most appreciated, but I'm looking for info that would allow me to create extensions to right-click menus in Explorer.
Also, how can I write a VB application that allows plugins or extensions, much like Paint.NET?
Thanks for any help!
drummerboy0511
|
|
|
|
|
You can do it with VB.NET or C#, but with great difficulty. There is a ton of COM interop you have to setup in your code and a bunch of structures you have to create and marshal properly. On top of that, there's a bit of an issue with using managed code to write Shell extensions. You can read about that here[^]. It amy force you to write this in C++ instead.
Beyond that, try these[^] examples. Most of which is going to be C#, but can be converted to VB.NET with a little work.
|
|
|
|