الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيفية اقتطاع حرف من كلمة

بدأه Gigaman في 6 يناير 2009 · 9 رد · 1,026 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

السلام عليكــم ورحمـة الله وبركاتــه

المثال خطأ موجود في المرفقات على فيجوال ستوديو 2008

كيفية اقتطاع حرف من كلمة

يعني اريد اقتطاع الاحرف لكل سطر

من كلمة ( المبرمجون ) في الليست بوكس

و النتيجة

ا

ل

م

ب

ر

م

ج

و

ن

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
		Dim str As String
		Dim strlenth As Integer
		Dim sobstr As String
		Dim m As Integer = 1
		Dim n As Integer = 0
		str = txt1.Text
		strlenth = str.Length
		For n = 0 To strlenth
			sobstr = str.Substring(n, strlenth)
			sobstr = lbl1.Text

		Next n

	End Sub
End Class

word_break.zip

تم تعديل هذه المشاركة بواسطة Gigaman في 6 يناير 2009 في 21:03

post-1386-1223033542.jpg
#2

مرحباً أخي الكريم .

جرب التالي :

 

[color= #000000; font-weight: bold;]Private [color= #000000; font-weight: bold;]Function MySplit[color= #009900;]( Byval CurrentText [color= #b1b100;]As String [color= #009900;]) [color= #b1b100;]As String

[color= #b1b100;]If CurrentText[color= #339933;].Length [color= #339933;]< [color= #cc66cc;]2 Then [color= #b1b100;]Return CurrentText

Dim NText [color= #b1b100;]As String [color= #339933;]= CurrentText[color= #009900;]([color= #cc66cc;]0[color= #009900;])[color= #339933;].ToString

[color= #b1b100;]For I [color= #b1b100;]As Integer [color= #339933;]= [color= #cc66cc;]1 To NText[color= #339933;].Length [color= #339933;]- [color= #cc66cc;]1

NText [color= #339933;]&= [color= #009900;]([color= #990000;]Chr[color= #009900;]([color= #cc66cc;]13 [color= #339933;]& [color= #990000;]Chr[color= #009900;]([color= #cc66cc;]10[color= #009900;]) [color= #009900;]) [color= #339933;]& NText[color= #009900;]( I [color= #009900;])

[color= #990000;]Next I

[color= #b1b100;]Return NText 

[color= #990000;]End [color= #000000; font-weight: bold;]Function

الاستخدام ( Usage ) :

 

[color= #000000; font-weight: bold;]Private Sub Btn1_Click[color= #009900;](ByVal Sender [color= #b1b100;]As [color= #990000;]System[color= #339933;].Object[color= #339933;], [color= #990000;]_

ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].EventArgs[color= #009900;]) Handles Btn1[color= #339933;].Click

Dim MySplitText [color= #b1b100;]As String [color= #339933;]= MySplit[color= #009900;]( Txt1[color= #339933;].Text [color= #009900;])

Lbl1[color= #339933;].Text [color= #339933;]= MySplitText

[color= #990000;]End Sub

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 6 يناير 2009 في 23:35

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#3

استخدم الدالة

.substring

#4

الاخ الفاضل Bashar Rabat

اشكرك شكرا جزيلا على الكود

لكن الكود لا يقطع سوى حرف واحد

و انا ارغب ان يقسم جميع الحروف و يضع كل حرف في لست بوكس

مثلا العربية

ا

ل

ع

ر

ب

ي

ة

السلام عليكم

الاخ العزيز Mohamed-Riadh

انا استخدمت ال substring

و لكن حاولت عملت لووب حتى تستطيع تغيير المكان باستخدام varibales متغيرات لكن لم تنجح العملية

post-1386-1223033542.jpg
#5

السلام عليكم

جرب الكود بالشكل التالى

		Dim i As Integer
		Dim str As String
		For i = 1 To Me.TextBox1.Text.Length
			str = Mid(TextBox1.Text, i, 1)
			Me.ListBox1.Items.Add(str)
		Next

{وَاتَّقُواْ يَوْمًا تُرْجَعُونَ فِيهِ إِلَى اللّهِ ثُمَّ تُوَفَّى كُلُّ نَفْسٍ مَّا كَسَبَتْ وَهُمْ لاَ يُظْلَمُونَ} (281) سورة البقرة

br17.gif

برنامج الإتصلات الإدارية والارشيف الالكتروني

برنامج الخبير لنقاط البيع المباشرة

#6
  1.  
  2. For Each chr As Char In txt1.Text
  3. lst1.Items.Add(chr)
  4. Next
  5.  

سبحان الله وبحمده ... سبحان الله العظيم

#7

عذراً, الـ Code الذي ادرجته, يقطع النص حرف حرف ويعيد نص على هيئة سطور, أنت لم تذكر مسبقاً أنك تريد إضافتهم إلى ListBox, يمكنك استخدام Code السيد أحمد مع إضافة .ToString بعد chr أي

 

[color= #b1b100;]For [color= #990000;]Each TChr [color= #b1b100;]As Char In Txt1[color= #339933;].Text

ListBox1[color= #339933;].Items[color= #339933;].Add[color= #009900;]( TChr[color= #339933;].ToString[color= #009900;]([color= #009900;]) [color= #009900;])

[color= #990000;]Next TChr

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 7 يناير 2009 في 23:52

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#8

السلام عليكــم ورحمـة الله وبركاتــه

اشكركم شكرا جزيلا

Bashar Rabat و المبرمج أحمد و waleedhm

يا شباب ابشركم الكود شغال مية مية

وهو

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click

		Me.lst1.Items.Clear()
		Dim i As Integer
		Dim str As String
		For i = 1 To Me.txt1.Text.Length
			str = Mid(txt1.Text, i, 1)
			Me.lst1.Items.Add(str)
		Next

	End Sub

وطبعا هذا كود الاخ waleedhm مع التعديل ليعمل على المشروع

وشكرا جزيلا للاخوة

و سأجرب الاكواد القادمة

للاخوة لان فيها افكار مختلفة اشويه

و سأوفيكم بالنتائج

post-1386-1223033542.jpg
#9

الحمدالله

الكود شغال بتاع الاخوين Bashar Rabat و المبرمج أحمد

طبعا في ملاحظة بسيطة على كود الاستاذ Bashar Rabat انه اضاف كلمة الى ولم يعمل الكود Chars

في السطر Txt.Text.Chars

و لكن الشكر الجزيل

فقد تعلمت ان لللحل عدة طرق ناجحة احسن من السب سترنق ب subsring

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click


		For Each TChr As Char In txt1.Text
			lst1.Items.Add(TChr.ToString())

		Next TChr
	End Sub

تم تعديل هذه المشاركة بواسطة Gigaman في 7 يناير 2009 في 22:23

post-1386-1223033542.jpg
#10

:$, أخذ بالي الـ Char , ههههه :D .

لكن يمكن استخدام الخاصية Chars كالتالي :

 

[color= #b1b100;]For I [color= #b1b100;]As Integer [color= #339933;]= [color= #cc66cc;]0 To Txt1[color= #339933;].Text[color= #339933;].Length [color= #339933;]- [color= #cc66cc;]1

ListBox1[color= #339933;].Items[color= #339933;].Add[color= #009900;](Txt1[color= #339933;].Text[color= #339933;].Chars[color= #009900;](I[color= #009900;])[color= #339933;].ToString[color= #009900;])

[color= #990000;]Next I

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 7 يناير 2009 في 23:56

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…